This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: base = scan.nextInt(); // Compute the maximum base 10 number that will fit in 4 digits // in the new base and tell the user what range the number they // want to convert must be in maxNumber = base * base * base * base - 1; System.out.println ("The maximum 4-digit number in base " + base + " is " + maxNumber + "."); System.out.print ("Please enter a base 10 number in the range 0 to " + maxNumber + " to convert: "); base10Num = scan.nextInt(); // Do the conversion (see notes in lab) place0 = base10Num % base; quotient = base10Num / base; place1 = quotient % base; quotient = quotient / base; place2 = quotient % base; quotient = quotient / base; place3 = quotient % base; quotient = quotient / base; // Print the result (see notes in lab) baseBNum = baseBNum + place3 + place2 + place1 + place0; System.out.println (base10Num + " (base 10) = " + baseBNum + " (base " + base + ")"); } }...
View Full Document
This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.
- Spring '10
- Computer Science