Santa Monica College Write a C++ Program Computer Programming Task

User Generated

g10987

Computer Science

Santa Monica College

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;

}

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

View attached ex...

Related Tags