Assignemnt #112: Odometer Loops
Code
/// Name: Cassie Rapp
/// Period: 6
/// Program Name: Odometer Loops
/// File Name: OdometerLoops.java
/// Date Finished: 5/3/2016
import java.util.Scanner;
public class OdometerLoops
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
int base = 0;
System.out.println( "what base? ( 2-10 ): " );
base = keyboard.nextInt();
for ( int thous=0; thous< base; thous++ )
for ( int hund=0; hund< base; hund++ )
for ( int tens=0; tens< base; tens++ )
for ( int ones=0; ones< base; ones++ )
{
System.out.print( " " + thous + "" + hund + "" + tens + "" + ones + "\r" );
Thread.sleep(10);
}
System.out.println();
}
}
/// 1. Yes it still works. It's like if/else statements without the braces. When only one line, it's ok.
Picture of the output