Question: Write a class potentially representing a String of binary digits (0s and 1s). Your constructor should take a String as its only parameter (that String

Write a class potentially representing a String of binary digits (0s and 1s). Your constructor should take a String as its only parameter (that String may contain only 0s and 1s, or it may not). Write a recursive method that checks whether that String contains 0s and 1s only. Write another recursive method that converts that String to its decimal equivalent. Your method should be different from the one in Exercise 48: it should take two parameters, the String representing the binary number, and an int representing an exponent. Your program should include a client class to test your class.

Exercise 48

Write a class with just one instance variable, a String representing a binary number. Write a recursive method taking only one parameter that converts that binary number to its decimal equivalent. Your program should include a client class to test your class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!