Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

=+ What jobs we will need in the future?

Answered: 1 week ago