1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const double MINTUES_IN_HOUR = 60;
const double OVERTIME_PAY = 1.5 * 8;
const string TIME_ERROR = "Invalid time. Please use (hh:mm A/P) format.";
bool validate_times ( int time1, int time2, char ap );
int main()
{
double payrate;
int start_hour, start_minute, end_hour, end_minute;
string name;
char colon, start_ap, end_ap;
cout << "Time Clock Program" << endl << endl
<< "Enter worker name: ";
getline(cin, name);
cout << "Enter start time (hh:mm A/P): ";
cin >> start_hour >> colon >> start_minute >> start_ap;
validate_times (start_hour , start_minute , start_ap);
cout << "Enter stop time (hh:mm A/P): ";
cin >> end_hour >> colon >> end_minute >> end_ap;
validate_times (end_hour , end_minute , end_ap);
cout << "Enter pay rate: ";
cin >> payrate;
system("pause");
return 0;
}
bool validate_times ( int time1, int time2, char ap )
{
if ( time1 > 12 )
return cout << TIME_ERROR;
else
if ( time2 > 59 )
return cout << TIME_ERROR;
else
if ( ap != 'a' || ap != 'p' )
return cout << TIME_ERROR;
}
|