In class I developed machinery to count in base 2. You can find it here. It consists of a class called Utility, containing all the basic methods and a class called Count containing a counting method. There was also a Driver to test the methods out by counting the first thousand integers using binary notation.
Your problem is to create a new class, call it Add, containing a method called add, to do binary addition. The method should take two String parameters, and return String. When given two base two names for non-negative integers, the method should return a name for the sum of the integers. Use my count as a model. You will also need to supply a new main, in which the user should be asked to type two base 2 number names, and their sum should be displayed.
In class I will discuss the recursive algorithm involved in binary addition. The base cases were are one of the names is empty (in this case the string returned is, simply, the other one). If neither string is empty, the algorithm divides into four cases, depending on the last digits of the two names. In one of the cases, my count method is needed.
Here is the algorithm in schematic form. If I write aaa0 I mean a number name ending in 0, with aaa as the sequence of digits before the final 0. Similarly with bbb0. Now, here is the algorithm for adding two base 2 number names.
count method that I wrote.