hello there, im given an assignment to basically prompt user to enter name, start time, end time, am or pm, and the pay rate and from that information i need to calculate number of hours worked and how much they get paid for the day, but im very stuck.
please excuse the completely unfinished program lol, but im just stuck, im want to getline for the start time and end time, but when im running the program, it skips the first (start) and only allows me to enter the end time, thus only getting my ending time. help! please
#include <iostream>
#include <string>
using namespace std;
int main()
{
string workerName;
string start; // MY TWO VARIABLES
string end;
int start_hour;
int start_min;
int end_hour;
int end_min;
float payRate;
float payCheck;
int totalHour;
int totalMin;
float overtime;
char amPm;
char amPm2;
cout << " Time Clock Program" << endl;
cout << "Enter worker name: " << endl;
cin >> workerName;
cout << "Enter Start time (hh:mm A/P): " << endl; // RIGHT HERE!
getline(cin, start);
cout << "Enter Stop time (hh:mm A/P): " << endl;
getline(cin, end);
cout << "Enter pay rate: " << endl;
cin >> payRate;
/*
if (start_hour <= 12)
{
if (end_hour <= 12)
totalHour = end_hour - start_hour;
}
else
cout << "Invalid time! Time set to 0:00" << endl;
if (start_min <= 59)
{
if (end_min <=59)
totalMin = end_hour - end_min;
}
else
cout << "Invalid time! Time set to 0:00" << endl;
cout << "Employee " << workerName << " has worked " << totalHour << " hours" << endl;
cout << overtime << endl;
cout << "The paycheck is for $" << payCheck << endl;
*/
cout << start << endl;
cout << end << endl;
return 0;
}