Description
in the space below write a c++ program that converts 12-hour time (including AM/PM) to 24 hour time. You must define an exception class called InvalidTime wherein if the user enters an out of range time or gibberish characters, your program will throw and catch InvalidTime.
For example, make your class support the following code:
TwelveHourTime sevenAM ( “7:00 AM” );
cout<< sevenAmM.twentyFourTime () <<endl;; //prints “ 07:00 “
TwelveHourTime eightPM ( “ 8:30 PM “ );
cout<< eightPM.twentyFourTime () << endl; // prints “20:30”
try
{
TwelveHourTime bad ( “ asef32422 ” );
//the previous line should throw an InvalidTime exception
} catch ( InvalidTime )
{
cout<< “ caught error as expected “ <<endl;
}
Explanation & Answer
View attached ex...
24/7 Study Help
Stuck on a study question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Similar Content
Related Tags
Communist Manifesto
by Karl Marx
Bridge to Terabithia
by Katherine Paterson
The Catcher in the Rye
by J. D. Salinger
Nervous Conditions
by Tsitsi Dangarembga
Murder on the Orient Express
by Agatha Christie
Cry the Beloved Country
by Alan Paton
The Secret Life of Bees
by Sue Monk Kidd
To the Lighthouse
by Virginia Woolf
100 Side Hustles
by Chris Guillebeau