Question: [Recursion: CLO: 5] [7.5 Pts] Important Note 1: Your program should compile and run correctly! To convert a number from the base-2 number (binary format)
[Recursion: CLO: 5] [7.5 Pts]
Important Note 1: Your program should compile and run correctly!
To convert a number from the base-2 number (binary format) to the base-10 (decimal) format, the following process is done.
Number (base 2) = 1110011
Number (base 10) = 1x26 + 1x25 + 1x24 + 0x23 + 0x22 + 1x21 + 1x20
= 64 + 32 + 16 + 0 + 0 + 2 + 1 = 115
The above binary-to-decimal algorithm can be implemented in two different ways:
- Iterative
- Recursive
- Complete the iter_bin2dec() method in the NumberConvert class to perform the iterative version of the binary to decimal format number conversion algorithm. Consider the following signature: [3 Pts]
public static int iter_bin2dec(String bin)
- Complete the recur_bin2dec() method in the NumberConvert class to perform the recursive version of the binary to decimal format number conversion algorithm. Consider the following signature: [3 Pts]
public static int recur_bin2dec(String bin, int start)
- Complete the test_bin2dec () method in the NumberConvert class to convert the binary number given as a String 1110011 [1.5 Pts]
public static void test_bin2dec()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
