Question: Java Problem 1: Write a recursive method dec2bin that accepts a positive decimal (base 10) integer as a parameter and returns a String that is

 Java Problem 1: Write a recursive method dec2bin that accepts a
positive decimal (base 10) integer as a parameter and returns a String
that is the binary representation of that integer. In the example on
the right, the base-10 number 4215 is repeatedly divided by 2 (using
Java

Problem 1: Write a recursive method dec2bin that accepts a positive decimal (base 10) integer as a parameter and returns a String that is the binary representation of that integer. In the example on the right, the base-10 number 4215 is repeatedly divided by 2 (using integer division) until it reaches O. At each stage the remainders are written on the right. The resulting binary number is the simply the remainders read from bottom to top. In the example, the output would be 1000001 110111. "LSB and "MSB" in the figure stand for the "least significant bit" and the "most significant bit" 2 4215 2 2107 2 1053 2 526 2263 2131 2 65 232 21 16 0 Note that with recursion you shouldn't have to store the remainders. 2L_o Write a main method to input a number from the user and display the resulting binary value

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 Databases Questions!