Question: Write a program in Java to read in a non-negative integer less than 128 and print out the binary representation. Use a method header like
Write a program in Java to read in a non-negative integer less than 128 and print out the binary representation. Use a method header like this: public static String intToBin(int x)
Ok so I need to be able to read in an integer and print out the binary representation as a string.
Also need a loop that does this.....example 18%2 = 0 18/2=9 9%2=1 9/2=4 4%2=0 4/2=2 2%2=0 2/2=1 ect..
And need a loop over all 8 bits, as this will need to be modified in next assignments.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
