Assignment #112 and Odometer Loops
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Odometer Loops
/// File Name: OdometerLoops.java
/// Date Finished: 1/28/2016
/// 1. Without the braces on the outer for loops, the program still works.
import java.util.Scanner;
public class OdometerLoops
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
System.out.print( "Pick a base (2-10): " );
int b = keyboard.nextInt();
for ( int thous=0; thous < b; thous++ )
for ( int hund=0; hund < b; hund++ )
for ( int tens=0; tens < b; tens++ )
for ( int ones=0; ones < b; ones++ )
{
System.out.print( " " + thous + "" + hund + "" + tens + "" + ones + "\r" );
Thread.sleep(500);
}
System.out.println();
}
}
Picture of the output