Assignment #112: Odometer Loops

Code

import java.util.Scanner;

public class OdometerLoops
{
    public static void main( String[] args ) throws Exception
    {
    
    Scanner kb = new Scanner(System.in);    
        
    int base;
        
    System.out.print("Choose a base: ");
    base = kb.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);
                    }
                
            
        //The code still works with the outer braces deleted.

        System.out.println();
    }
}
    

Picture of the output