Need help on following program using c language Please provi

Need help on following program using c++ language. Please provide all three file seprate with title header file, implemntation file and main file.

Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation. Your program must contain three exception classes: invalidHr, invalidMin, and invalidSec. If the user enters an invalid value for hours, then the program should throw and catch an invalidHr object. Similar conventions for the invalid values of minutes and seconds.

Please provide all three files.

Solution

#include #include \"ConvertTime.h\" using namespace std; int main() { convertTime convert; int hr, min, sec; cout << \"Please input time in 12 hr notation\"; cin >> hr >> min >> sec; convert.invalidHr(hr); //to convert hours to 24 hour format convert.invalidMin(min);//to convert minutes to 24 hour format convert.invalidSec(sec);//to convert seconds to 24 hour format convert.printTime(); return 0; } #include #include \"ConvertTime.h\" using namespace std; void convertTime::invalidHr (int hr)//function to convert hours in 24 hour format { if (hr > 0 && hr < 13) hr = hr + 12; else cout << \"Ivalid input! Please input hour again in correct 12 hour format: \"; cin >> hr; invalidHr(hr); } void convertTime::invalidMin (int min) //function for converting minutes { if (min < 60 && min > 0) min = min; else cout << \"Please input minutes again in correct 12 hour format: \"; cin >> min; invalidMin(min); } void convertTime::invalidSec(int sec) //function for converting seconds { if (sec < 60 && sec > 0) sec = sec; else cout << \"Please input seconds again in correct 12 hour format: \"; cin >> sec; invalidSec(sec); } void convertTime::printMilTime() { cout << \"The converted time in 24hour format is: \" << hour << \":\" << min << \":\" << sec; }
Need help on following program using c++ language. Please provide all three file seprate with title header file, implemntation file and main file. Write a progr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site