Can Anyone help me on following program for c language Pleas

Can Anyone help me on following program for c++ language. Please provide main file, header file and implementation files seprate.

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.

Solution

#include <iostream>
#include \"Cnvrttimeheader.h\"
using namespace std;
int main()
{
convertTime convert;
int hr, mn, sc = 0;
cout << \"Input hours in 12 hr notation: \";
cin >> hr;
cout << \"input minutes: \";
cin >> mn;
cout << \"input seconds: \";
cin >> sc;
convertHour = hour;
convertMin = min;
convertSec = sec;
convert.printMilTime();
system(\"Pause\");
return 0;
}


#include <iostream>
#include \"CnvrtTimeHeader.h\"
using namespace std;
int convertTime::invalidHr (int hour)
{
try
{
if (hour < 13 && hour > 0)
{hour = hour + 12;
return hour;
}
else
{
cin.clear();
cin.ignore();
cout << \"Invalid input! Please input hour again in correct 12 hour format: \";
cin >> hour;
invalidHr(hour);
throw 10;
}

}
catch (int c) { cout << \"Invalid hour input!\";}
}

int convertTime::invalidMin (int min)
{
try{
if (min < 60 && min > 0)
{return min;}
else{

cin.clear();
cin.ignore();
cout << \"Incorrect input... input minutes again in correct 12 hour format: \";
cin >> min;
invalidMin(min);
throw 20;
return 0;
}
}
catch (int e)
{
cout << \"Invalid minute input\" << endl;}
}
int convertTime::invalidSec(int sec)
{
try
{
if (sec < 60 && sec > 0)
{
return sec;
}
else
{
cin.clear();
cin.ignore();
cout << \"Incorrect input...input seconds again in correct 12 hour format: \";
cin >> sec;
invalidSec(sec);
throw 30;
return 0;
}
}
catch (int t)
{
cout << \"Invalid second input!\" << endl;
}
}
void convertTime::printMilTime()
{
cout << \"Your time is now converted: \" << hour << \":\" << min << \":\" << sec;
}

Can Anyone help me on following program for c++ language. Please provide main file, header file and implementation files seprate. Write a program that prompts t
Can Anyone help me on following program for c++ language. Please provide main file, header file and implementation files seprate. Write a program that prompts t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site