// // Supporting material for lecture 8 // - make a while out of a for // - reading & validating time // import FormatIO.*; public class Demo08 { public static void main(String[] args){ Console con = new Console(); int time = 0, hours = 24, minutes = 60; for (boolean legal=false;!legal;legal = hours < 24 && minutes < 60){ con.print("Enter time: "); time = con.readInt(); hours = time / 100; minutes = time % 100; } con.println("done"); } } // // (1) How come we declared time, hours, minutes that way? // (2) What is a legal time? // (3) for, but not using incrementing, but as a while // (4) Can we be neater/shorter? // (5) why bother with while? // - syntactic sugar // (6) Have we properly validated time? // - do we allow negative time? // - why did we not think of this? //