Code:
#include <iostream.h>
int main()
{
// declare variables
int ampm;
int start_hour, start_min, stop_hour, stop_min;
int min_check, hour_check;
int check_error1, check_error2, check_error3;
int hold;
// get info from user
cout << "Enter the starting hour. " << endl;
cin >> start_hour;
cout << "Enter the starting minute. " << endl;
cin >> start_min;
cout << "Enter the stopping hour. " << endl;
cin >> stop_hour;
cout << "Enter the stopping minute. " << endl;
cin >> stop_min;
cout << "Enter if Am or Pm." << endl;
cout << "1 - AM" << endl;
cout << "2 - PM" << endl;
cout << "Please choose the number:" << endl;
cin >> ampm;
// sees if babysitter works in the evening or morning with switch statement
switch(ampm)
{
case 1:
cout << "The Babysitter doesn't work in the morning. Please try again." << endl;
break;
case 2:
cout << "Ok. Information is good." << endl;
break;
default:
cout << "Please enter a valid number." << endl;
break;
}
// invalid statements
check_error3 = ((ampm = 1) && (start_hour <6) && (stop_hour >12));
if (check_error3 == 0)
cout << "Your data is invalid." << endl;
else
cout << "Ok Data." << endl;
if (ampm == 1)
cout << "Invalid data" << endl;
else
cout << "Ok." << endl;
// calculate babysitters wages
min_check = stop_min - start_min;
hour_check = stop_hour - start_hour;
check_error1 = ((ampm = 2) && (start_hour >=6) && (stop_hour <=9) && (stop_min = 30)) ||
((ampm = 2) && (start_hour >=9 && start_min >=30) && (stop_hour <=12));
if (check_error1 == 0)
cout << "Wrong Information. Please try again." << endl;
else
cout << "Good information." << endl;
if (start_hour >=6 && stop_hour <=9 && stop_min <=30 )
cout << "Your charges are $ " << (hour_check * 3) << endl;
else
cout << "Your charges are $ " << ((hour_check * 5)-2) << endl;
cin >> hold;
return 0;
}
Code tags added by Kermi3