// // Supporting material for lecture 11 // - helper methods // - validating time, again :) // read in two times and then do soemthing with them!!! // import FormatIO.*; public class Demo11a { public static void main(String[] args){ Console con = new Console(); int firstTime = -999, secondTime = -999; while (!validTime(firstTime)){ con.print("Enter first time: "); firstTime = con.readInt(); } while (!validTime(secondTime)){ con.print("Enter second time: "); secondTime = con.readInt(); } con.println("Diff: " + (firstTime - secondTime)); // (9) } private static boolean validTime(int x){ return x > 0 && x/100 < 24 && x%100 < 60; } } // // Same as Demo11, all that we have done is declare method validTime after we have used it // I prefer Demo11 to Demo11a // // How would we measure the difference between two // times in 24 hour format? //