Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code needs to be in C++ Sample Output: Enter time in 24-hour notation: 13:07 Tha

ID: 3780081 • Letter: C

Question

Code needs to be in C++


Sample Output: Enter time in 24-hour notation: 13:07 That is the same as 1:07 PM Again (y/n)? y Enter time in 24-hour notation: 10:15 That is the same as 10:15 AM Again (y/n)? y Enter time in 24-hour notation: 10:67 There is no such time as 10:67. Try again. Enter time in 24-hour notation: %9:&5 There is no such time as %9:&5. Try again. Enter time in 24-hour notation: 16:05 That is the same as 4:05 PM Again (y/n)? n End of Program Sample Output: Enter time in 24-hour notation: 13:07 That is the same as 1:07 PM Again (y/n)? y Enter time in 24-hour notation: 10:15 That is the same as 10:15 AM Again (y/n)? y Enter time in 24-hour notation: 10:67 There is no such time as 10:67. Try again. Enter time in 24-hour notation: %9:&5 There is no such time as %9:&5. Try again. Enter time in 24-hour notation: 16:05 That is the same as 4:05 PM Again (y/n)? n End of Program Due date: 12/6/16 Project 3: Time Converter Your task: Write a program that converts 24-hour time to 12-hour time. You will define an exception class called Time FormatMistake. If the user enters an illegal time, like 10:67 or even gibberish like %9:&5, then your program will throw and catch a Time FormatMistake exception Class Definition The TimeFormatMistake class must have at least: o One default constructor, o One argumented constructor, o One getter function to retrieve the one data member o One string data member: message. This data member will be used to display the following dialog: "There is no such time as

Explanation / Answer

/** Instead of handling exception with the class TimeFormatMistake, I have handled all exceptions of hour, minute and sec separately. Yo can club all three and rename them if you want. **/ #include #include "ConvertTimeHeader.h" using namespace std; int main() { convertTime convert; int hour, min, sec; cout > hour >> min >> sec; convert.invalidHr(hour); convert.invalidMin(min); convert.invalidSec(sec); convert.printMilTime(); system("Pause"); return 0; } #include #include "ConvertTimeHeader.h" using namespace std; void convertTime::invalidHr (int hour) { try{ if (hour > 0 && hour < 13) hour = hour + 12; else { cin.clear(); cin.ignore(); cout > hour; invalidHr(hour); } } catch (...) { cout 0) min = min; else cin.clear(); cin.ignore(); cout > min; invalidMin(min); } catch (...) { cout 0) sec = sec; else cin.clear(); cin.ignore(); cout > sec; invalidSec(sec); } catch (...) { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote