/* * Intro to Programming CSE 1310 * University of Texas at Arlington */ package test2questiona; import java.util.Scanner; /** * * @author jcmtiernan */ public class Test2QuestionA { /** * @param args the command line arguments */ public static void main(String[] args) { int[] values = new int[25]; int d = 2; int i = 0; int n = 0; Scanner input = new Scanner(System.in); System.out.print("Please enter a whole number: "); n = input.nextInt(); for (; (i < 25) && (n > 1); i++) { values[i] = n % d; n = n / d; } values[i] = n; for (int c = i; c >= 0; c--) System.out.printf("%1d",values[c]); System.out.println(""); } }