Odometer Loops

Download the following code, and get it to compile.

Files Needed

What You Should See


(It looks a little cooler in person.)

Study Drills

  1. Delete all the open curly braces and close curly braces from all the outer for loops. (Leave the curly braces that belong to the innermost loop (the "ones" loop).) Does it still work? Answer in a comment.
  2. Change all the loops so that they count from 0 to 7 instead of 0 to 9. This will display numbers in "octal" (base 8) instead of "decimal" (base 10).
  3. Change the code so that the human gets to type in a number for the base, and your odometer counts up to that instead of 8. You might want to increase the delay (put a bigger number (like maybe 500) inside the 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

©2013–2016 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License