You can also download text file of this code here: BinaryConverter.txt Java Code: public class BinaryConv { public static void main(String[] args) { Scanner in = new Scanner(System.in); int decimalNumber; String binaryNumber; System.out.print("Enter a positive integer: "); decimalNumber = in.nextInt(); if (decimalNumber <= 0) System.out.println("ERROR: entered integer is nonpositive."); else { binaryNumber = ""; // algorithm step by step // initial: binaryNumber = "", decimalNumber = 123 // step 1 : binaryNumber = "1 ", decimalNumber = 61 // step 2 : binaryNumber = "11 ", decimalNumber = 30 // step 3 : binaryNumber = "011 ", decimalNumber = 15 // step 4 : binaryNumber = "1011 ", decimalNumber = 7 // step 5 : binaryNumber = "1 1011 ", decimalNumber = 3 // step 6 : binaryNumber = "11 1011 ", decimalNumber = 1 // step 6 : binaryNumber = "111 1011 ",
Get Started... Get Addicted...