Hello everyone,

I was given a code that was not in the correct order. I have the first half of the program in the right order I believe but need help with the rest. The program is supposed to output the total time an employee spent on the job each day. The program asks the user to enter the employees name, arrival time and departure time. The program will also allow the user to run the program as long as the user wishes.

Here is the code:

#include<iostream>
#include<string>

using namespace std;

int main()
{
string employeeName;
int arrivalHr;
int arrivalMin;
bool arrivalAM;

int departureHr;
int departureMin;
bool departureAM;

char response;
char discard;
char isAM;

cout << "This program calculates the total time spent by an "
<< "employee on the job." <<endl;
cout << "To run the program, enter (y/Y): ";
cin >> response;
cout endl;
cin.get(discard);

while (response =='y' || response == 'Y')
{
cout << "Enter employee's name: ";
getline(cin, employeeName);
cout << endl;

cout << "Enter arrival hour: ";
cin >> arrivalHr;
cout >> endl;
cout << "Enter arrival minute: ";
cin >> arrivalMin;
cout << endl;
cout << "Enter (y/Y) if arrival is before 12:00PM: ";
cin >> isAM;
cout << endl;

if (isAM == 'y' || isAM == 'Y')
arrivelAM = true;
else
arrivelAM = false;

cout << "Enter departure hour; ";
cin >> departureHr;
cout << endl;
cout << "Enter departure minute; ";
cin >> departureMin;
cout << endl;
cout << "Enter (y/Y) if departure is before 12:00PM: ";
cin >> isAM;
cout << endl;

if (isAM == 'y' || isAM == 'Y')
departureAM = true;
else
departureAM = false;

cout<< employeeName << endl;
timeOnJob(arrivalHr, arrivalMin, arrivalAM, departureHr, departureMin, departureAM);

bout << "Run program again (y/Y): ";
cin >> response;
cout << endl;
cin.get(discard);
} 
return 0;
}

void timeOnJob(int arvHr, int arvMin, bool arvIsAM, int depHr, int depMin, bool depIsAM)

{
int arvTimeInMin;
int depTimeInMin;
int timeOnJobInMin;

else if (arvIsAM == true && depIsAM == false)
{
arvTimeInMin = arvHr * 60 + arvMin;
depTimeInMin = depHr * 60 + depMin;

timeOnJobInMin = (720 - arvTimeInMin) + depTimeInMin;
cout << "Time spent of job: "
<< timeOnJobInMin / 60 << " hour(s) and "
<< timeOnJobInMin % 60 << " minutes." << endl;
}

else 
if (arvTimeInMin <= depTimeInMin)
{
timeOnJobMin = depTimeInMin - arvTimeInMin;
cout << "Time spent of job: "
<< timeOnJobInMin / 60 << " hour(s) and "
<< timeOnJobInMin % 60 << " minutes." << endl;
}
else
cout << "Invalid input." << endl;
if (( arvIsAM == true && depIsAM == true)
|| (arvIsAM ==false && depIsAM == false))
{
cout << "Invalid input." << endl;
}
void timeOnJob(int arvHr, int arvMin, bool arvIsAM, int depHr, int depMin, bool depIsAM;
}

Recommended Answers

All 4 Replies

What do you need help with? The compilation errors are a minor deal.

What do you need help with? The compilation errors are a minor deal.

I need help putting the code in the correct order so the program runs and executes properly.

Btw, Your program doesn't compile in the first place. Clear those out so you can go on to test it !

Btw, Your program doesn't compile in the first place. Clear those out so you can go on to test it !

ahhh! your worthless! Can someone else help me?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.