Question: solve 3.14 LAB: Convert to reverse binary Write a program that takes in a positive integer as input, and outputs a string of 1's and

solve

3.14 LAB: Convert to reverse binary Write a program that takes in a positive integer as input, and outputs a string of 1's and O's representing the integer in reverse binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x $ 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. Ex: If the input is: 6 the output is: 011 6 in binary is 110; the algorithm outputs the bits in reverse. 660918.3308628.qx3zqy7 LAB ACTIVITY 3.14.1: LAB: Convert to reverse binary 0 / 10 LabProgram.java Load default template.. 1 import java. util. Scanner; //importing scanner Library public class ; Main { //creating class public static void main(String args) { Scanner scan = new Scanner (System. in) ; //declaring scanner function int inputInt; inputInt = scan. nextInt(); 10 //storing scanned input variable 11 12 while(inputInt0) { // while Loop 13 System. out . print(inputInt*2); //modulus of input 14 value and; 15 inputInt = inputInt / 2; //convering to binary 16 } 17 System. out . println( ); }} 18

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