import java.io.PrintStream; import java.util.Scanner; import type.lib.ToolBox; /** * This app implements a solution to Exercise Check11A on p. 441 of Java By Abstraction. * * @author [INSERT YOUR NAME/STUDENT NUMBER HERE] * */ public class Check11A { public static void main(String[] args) { PrintStream output = System.out; Scanner input = new Scanner(System.in); /* * Step 1: Cut and paste your solution from last week's Exercise02 here. * * Modify your code so that the try block encapsulates *all* of the * statements (rather than placing some statements outside of the try * block). There should be a single ArrayIndexOutOfBoundsException catch * block after the try block. * * Remove the System.exit(0) statement from the catch block, since it is * no longer necessary. * * Change the prompt to "Enter h:m:AM or PM > " * * Change the output so that only the numerical value is printed out, * without any string prefix. * * Ensure that there is only a single line of output. */ /* * Step 2: now run eCheck on your solution. * * java eCheck 11A * * Run eCheck at least 10 times. Over these test runs, you will see that * the automated checking fails each time. Each time, a different reason * will be reported. * * Your task is to augment the code above so that it satisfies all of * the test cases used by eCheck. You can address each of the various * requirements by re-using your code from Exercise03-06 from last * week's lab exercises. You can copy and paste the code segments here. * You may need to rejig the order of the steps. * * Note that the "Missing colon!" case was not covered in the previous * exercises. You should read and parse the first token, then check for * the second token. If the second token cannot be found, then a * RuntimeException should be thrown with the meesage "Missing colon!". * Similarly, once the second token is read and parsed, then check for * the third token (with similar exception handling). * * Do not use System.exit(0) at all, since this will cause eCheck to * malfunction. * * There should be one large try block with multiple catch blocks, * arranged as needed. Be careful that you arrange your catch blocks in the * correct order. * * This exercise can be challenging because you need to make use of the * feedback from eCheck in order to iteratively modify your code. * * You may get feedback that you have too many terminated statements * (TS's). Try various approaches to reduce the number of TS's down to * 32 (eCheck will accept solutions this long, but not longer). * * This step has been completed when you see the following line of * feedback from eCheck: * * "* Your app has been successfully checked and recorded." * * DUE DATE: 11:59pm, Monday Jan 23rd. */ } }