+1 714-215-3097

(Solved) : Write C Console Application Defines Datehandler Class Timehandler Exceptionhandler Class A Q35544609

Write a C++ console application that defines: a DateHandlerclass, a TimeHandler, and an ExceptionHandler class.

This application will take in a date/time in standard format,and return the date/time in military format. 1:00 AM is 01:00 inmilitary time. 1:00 PM in standard time is 13:00 in military time.The standard date format is: MM/DD/YYYY (m = month, d = day, y =year); the military date format is: YYYY/MM/DD (4 digit year, 2digit month, 2 digit day).

The following website provides a convenient table for convertingstandard time to military time: (Links to an externalsite.)Links to an external site.

For this assignment, an example of the correct input format is:01/19/2019 04:30:31 PM, where MM/DD/YYYY HH:MM:SS Meridian. Anexample of the correct output format is: 2019/01/19 16:30:31, whereYYYY/MM/DD HH:MM:SS.

The ExceptionHandler class should be derived from the<exception> class. Define a private data field named’message’ of type string, that will contain an error messages thatyou specify. The default constructor should take a string in as aparameter, and set ‘message’ to that parameter. Override the.what() method from the <exception> class, and have yourdefinition of the .what() method return ‘message’.

The DateHandler class only needs one method. This method willtake in a string in, expecting the format of MM/DD/YYYY HH:MM:SSMeridian. This method will only convert the date portion of theinput. The time portion of the input will be passed to an instanceof the TimeHandler class for conversion. The method should firstcheck the input string to verify that no errors exist in theformat, convert the date to military date, pass the time to aTimeHandler object, concatenate the result from the TimeHandlerwith the converted date, and return that result. If any errorsexist in the format, throw a detailed message of what the error is.If an error is caught from the TimeHandler object, that errorshould be thrown back to main. The returned result should be in theformat of YYYY/MM/DD HH:MM:SS.

The TimeHandler class only needs one method. This method willtake a string in, expecting the format of HH:MM:SS Meridian. Thismethod will check that the format is valid, convert the time tomilitary time, and return the result as a string. If there are anyerrors in the format, throw a detailed description of the error.The returned result should be in the format: HH:MM:SS.

The type of errors that you could receive are:

  • Input string too long/short   
  • Anywhere an integer is expected, an invalid numberexists   
  • Months 0 and 13+ do not exist   
  • Days in a month can’t exceed 31   
  • Hours 0 and 13+ do not exist (standardtime)   
  • Minutes 60+ do not exist   
  • Seconds 60+ do not exist

From main, prompt the user for a date/time in the standardformat and then try to convert to military date/time. Catch anyexceptions and print any exception messages. If the date/time issuccessfully converted, print the result. Use a loop to allow theuser to repeatedly convert date/time.

Leave a Reply

Your email address will not be published. Required fields are marked *