// // Supporting material for lecture 7 // - reading in and validating time // - using while // import FormatIO.*; public class Demo07 { public static void main(String[] args){ Console con = new Console(); int time = 0, hours = 0, minutes = 0; boolean legal = false; while (!legal){ con.print("Enter time: "); time = con.readInt(); hours = time / 100; minutes = time % 100; System.out.println(time + " " + hours + " " + minutes); legal = hours < 24 && minutes < 60; // (2) con.println(legal); } con.println("done"); } } // // (1) How come we declared time, hours, minutes that way? // (2) What is a legal time? // (3) Can we be neater/shorter? // (4) Can we get it to use the console? // (5) Can we encapsulate this in some way? //