import java.util.Scanner; /* Java application having as its purpose to test the TimeOfDay12Or24 class. */ public class TimeOfDay12Or24Tester { private static Scanner input; public static void main(String[] args) { input = new Scanner(System.in); // establishes keyboard as input source boolean keepGoing = true; while (keepGoing) { try { doOneTest(); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); } catch (Exception e) { System.out.println(e.toString()); keepGoing = false; } } System.out.println("\nGoodbye."); } private static void doOneTest() { System.out.print("\nEnter an hour [0..24) and a minute [0..60): "); int h = input.nextInt(); int m = input.nextInt(); TimeOfDay12Or24 time = new TimeOfDay12Or24(h,m); System.out.println("Time of day (in 24-hour mode) is " + time.toString()); time.setToMode12(); System.out.println("Time of day (in 12-hour mode) is " + time.toString()); } }