Download the following code, and get it to compile.
public class OdometerLoops { public static void main( String[] args ) throws Exception { for ( int thous=0; thous<10; thous++ ) { for ( int hund=0; hund<10; hund++ ) { for ( int tens=0; tens<10; tens++ ) { for ( int ones=0; ones<10; ones++ ) { System.out.print( " " + thous + "" + hund + "" + tens + "" + ones + "\r" ); Thread.sleep(10); } } } } System.out.println(); } }
9999
(It looks a little cooler in person.)
Assignments turned in without these things will receive no credit.
for
loops. (Leave the curly braces that belong
to the innermost loop (the "ones" loop).) Does it still work? Answer
in a comment.
Thread.sleep()
).
After you've made all the changes, it should look something like this (except that all your numbers will be overwriting each other on the same line instead of printing on separate lines):
Which base (2-10): 2 0000 0001 0010 0011 0100 0101
©2013 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.