Question: Write an interactive program in Java which accepts a positive integer value from a user and then displays the binary equivalent of that value. The
Write an interactive program in Java which accepts a positive integer value from a user and then displays the binary equivalent of that value. The program should allow the user to repeat this process until the user chooses to quit.
For example, if the number 13 is the parameter, then the method should return the String 1101. Your method should perform the conversion by implementing the algorithm shown in pseudocode below:
-
read a number n
-
while n > 0
-
remainder = n % 2
-
push remainder onto a stack
3. n=n/2
-
-
while the stack is not empty Pop an element and add it to the output String
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
