Assignment #112 Odometer Loops
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Odometer Loops
/// File Name: OdometerLoops.java
/// Date Finished: 4/18/2016
import java.util.Scanner;
public class OdometerLoops
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
int base;
System.out.println();
System.out.print( "Which base (2-10): " );
base = keyboard.nextInt();
for ( int thous=0; thous<=base-1; thous++ )
for ( int hund=0; hund<=base-1; hund++ )
for ( int tens=0; tens<=base-1; tens++ )
for ( int ones=0; ones<=base-1; ones++ )
System.out.print( " " + thous + "" + hund + "" + tens + "" + ones + "\r" );
Thread.sleep(1000);
//The for statement still works
System.out.println();
}
}
Picture of the output