Need help on following program using c++ language. Please provide all three file
ID: 3931339 • Letter: N
Question
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.
Explanation / Answer
#include #include "ConvertTime.h" using namespace std; int main() { convertTime convert; int hr, min, sec; cout > 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 > hr; invalidHr(hr); } void convertTime::invalidMin (int min) //function for converting minutes { if (min < 60 && min > 0) min = min; else cout > min; invalidMin(min); } void convertTime::invalidSec(int sec) //function for converting seconds { if (sec < 60 && sec > 0) sec = sec; else cout > sec; invalidSec(sec); } void convertTime::printMilTime() { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.