English subtitles

← Clock Times - Intro to Java Programming

Get Embed Code
5 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

  1. Let's get some practice with nested loops. This digital clock can display any
  2. time of day. It's an American clock, so the hours go from 1 to 12 and minutes
  3. go from 00 to 59. We can use a nested loop to print this table of all of the
  4. possible times the digital clock can display. We'll need two loops. One will
  5. count up the hours, and one will count up the minutes. To make sure that
  6. minutes are printed with a zero before them so they fill up two digits, you can
  7. use the format string %02d. And if you're not sure where to start while writing
  8. your code, think about what code you would write just to print the first line.
  9. And how that differs from the code that you would write to print the second
  10. line.