Question: c++ Exception Handling Write a program that prompts the user to enter time in 24-hour notation. The program outputs the time in 12-hour notation. The

c++

Exception Handling

Write a program that prompts the user to enter time in 24-hour notation. The program outputs the time in 12-hour notation. The program must contain three get functions for "hours", "minutes" and seconds". These get functions ask the user for the input values and handle exceptions with try and catch blocks. Your program must contain three exception classes: InvalidHrExcep, InvalidMinExcep, and InvalidSecExcep. If the user enters an invalid value for hours, then the program should throw and catch an InvalidHr object. If the user enters an invalid value for minutes, then the program should throw and catch an InvalidMinExcep object. If the user enters an invalid value for seconds, then the program should throw and catch an InvalidSecExcep object. You need to define the exception classes in their own header files using the following convention:

/ / Userde f ined excep t ion c l a s s . #include #include using namespace s td ; c lass myExceptionClass { public : myExceptionClass ( ) / / de fau l t con s t ruc to r { message = " my message " ; } myExceptionClass ( s t rin g s t r ) / / overloaded con s t ruc to r { message = s t r ; } s t rin g what ( ) / / c a l l t h i s " ge t " func t ion when p r in i t ing / / the excep t ion message { return message ; } pr ivate : s t rin g message ; } ;

Additional requirements and instructions:

No use of global variables.

Code is well commented. Comments for functions describe what they do. They also describe the post conditions. If parameter names are not descriptive in function headers, the comments for a function describe the pre conditions as well. Submit all code files needed to compile and run this program. Comply with syllabus policies .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!