Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Problem Write a C++ program to calculate the pay for an employee. Th

ID: 3679251 • Letter: P

Question

Programming Problem Write a C++ program to calculate the pay for an employee. The program inputs the pay rate and the number of hours worked from the user. The program echoes the input information and outputs the calculated pay. Include a void function, called GetData, which takes two arguments and inputs the pay rate and the number of hours worked Include another value returned function, called CalcPay, which takes two arguments and returns the total pay for that employee Include a final void function, called PrintPay, which takes three arguments and outputs the input information and the calculated tota pay. The sample output for the program should looks like the following: This program calculates total pay for an employee please enter pay rate per hour: 15.66 Please enter hours worked 200.5 For an employee who worked 200.5 hours with a pay rate 15.66 per hour, The total pay is 3139.83 Press any key to continue

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;
void getData(int , float , float);
float calculatePay (int, float,float);
void printPaySlip(int,float,float,float);
int main()
{
int empno;
float theHoursWorked;
float thePayRate;
float thePay;

for (int i = 0; i < 5; i++)
{
getData(empno,theHoursWorked,thePayRate);
thePay = calculatePay (empno, theHoursWorked, thePayRate);
printPaySlip(empno,theHoursWorked,thePayRate,thePay);
}
return 0;
}
void getData (int empno, float theHoursWorked, float thePayRate)
{
cout<< "Enter your name and surname: "<< endl;
cin>> empno;
cout << "Include the numbers of hours you worked: " << endl;
cin >> theHoursWorked;
cout << "What is your hourly pay rate?" << endl;
cin >> thePayRate;
}

float calculatePay( int empno, float theHoursWorked, float thePayRate)
{
float tempPay, thePay, overtimeHours,overtimepayment;
if (theHoursWorked > 40)
{
tempPay = 40 * thePayRate;
overtimeHours = theHoursWorked - 40;
overtimepayment=overtimeHours*thePayRate;
thePay = tempPay + overtimepayment;
  
}
else

thePay = theHoursWorked * thePayRate;
return thePay;
}

void printPaySlip( int empno, float theHoursWorked, float thePayRate, float thePay)
{
cout << "Pay slip for " << empno <<endl;
cout << "Hours worked: "<< theHoursWorked << endl;
cout << "Hourly pay rate: " << thePayRate << endl;
cout << "Pay: " << thePay << endl;
cout << press any key to continue << endl;
}