This assignment uses the Time class, which is available on the class web page. To receive credit for this assignment, you must not modify the Time class in any way except as listed here:This assignment uses the Time class, which is available on the class web page. To receive credit for this assignment, you must not modify the Time class in any way except as listed here:

Modify the class so that it may throw 3 different classes of exceptions, each of which is defined by you:

  • Attempting to set the hour portion of a Time object to an illegal value (i.e., not within the range 0..23)
  • Attempting to set the minute portion of a Time object to an illegal value (i.e., not within the range 0..59)
  • Attempting to set the second portion of a Time object to an illegal value (i.e., not within the range 0..59)

Make sure you use descriptive names for your exception classes, and also that your exceptions are checked exceptions.

Now write a test class with a main() method that reads the data for Time objects from a file (which I will supply) until eof. For each line read, create a Time object and call toString() to print it in a.m./p.m. format. Then close the file.

  • All exceptions must be handled in main, including any standard java exceptions that may be thrown, such as a FileNotFoundException or NumberFormatException
  • You may assume that each line of the file contains three tokens
  • If an exception is thrown, the output must include the data read and a detailed description of the exception (see the Date class, online)
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.