Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ console application that defines: a DateHandler class, a TimeHandler, and an ExceptionHandler class. This application will take in a date/time in standard

Write a C++ console application that defines: a DateHandler class, 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 in military 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, 2 digit month, 2 digit day).
The following website provides a convenient table for converting standard time to military time:
http://www.aaamath.com/meatm2s.htm
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. An example of the correct output format is: 2019/01/19 16:30:31, where YYYY/MM/DD HH:MM:SS.
The ExceptionHandler class should be derived from the class. Define a private data field named 'message' of type string, that will contain an error messages that you specify. The default constructor should take a string in as a parameter, and set 'message' to that parameter. Override the .what() method from the class, and have your definition of the .what() method return 'message'.
The DateHandler class only needs one method. This method will take in a string in, expecting the format of MM/DD/YYYY HH:MM:SS Meridian. This method will only convert the date portion of the input. The time portion of the input will be passed to an instance of the TimeHandler class for conversion. The method should first check the input string to verify that no errors exist in the format, convert the date to military date, pass the time to a TimeHandler object, concatenate the result from the TimeHandler with the converted date, and return that result. If any errors exist in the format, throw a detailed message of what the error is. If an error is caught from the TimeHandler object, that error should be thrown back to main. The returned result should be in the format of YYYY/MM/DD HH:MM:SS.
The TimeHandler class only needs one method. This method will take a string in, expecting the format of HH:MM:SS Meridian. This method will check that the format is valid, convert the time to military time, and return the result as a string. If there are any errors 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 number exists
Months 0 and 13+ do not exist
Days in a month can't exceed 31
Hours 0 and 13+ do not exist (standard time)
Minutes 60+ do not exist
Seconds 60+ do not exist
From main, prompt the user for a date/time in the standard format and then try to convert to military date/time. Catch any exceptions and print any exception messages. If the date/time is successfully converted, print the result. Use a loop to allow the user to repeatedly convert date/time.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions