Question: here is the question and the code whats wrong i keep getting errors The payroll manager at Gerston Blankets wants a program that calculates and
here is the question and the code whats wrong i keep getting errors
The payroll manager at Gerston Blankets wants a program that calculates and displays the gross pay for
each of the companys employees. It also should calculate and display the total gross pay. The payroll manager will enter the number of hours the employee worked and his or her pay rate. Employees
working more than 40 hours should receive time and one-half for the hours over 40. Use a value- returning function to determine an employees gross pay. Use a different value-returning function to
accumulate the total gross pay. The program should display the total gross pay only after the payroll manager has finished entering the data for all the employees. Use a sentinel value to end the program.
C++ code:
#include
#include
using namespace std;
// prototypes
double getGrossPay(int hours, double payRate, double &grossPay);
double calcTotalGross(double grossPay, double totalGross);
int main()
{
// delare
int hours = 0;
double payRate = 0;
double grossPay = 0;
double totalGrossPay = 0;
cout << "Hours worked: ";
cin >> hours;
if (hours != -1)
{
cout << "Pay rate:";
cin >> hours;
}
while (hours != -1)
{
getGrossPay(hours, payRate, grossPay);
totalGrossPay = calcTotalGross(grossPay, totalGrossPay);
cout << "Hours worked";
cin >> hours;
if (hours != -1)
{
cout << "Payrate";
cin >> payRate;
}
}//endwhile
//display the total gross pay
cout << fixed << setprecision(2);
cout << "Total gross pay is $" << totalGrossPay <<
endl;
system("pause");
return 0;
// function def
double getGrossPay(int hours, double payRate, double &grossPay);
{
//declare variables
int overtimeHours = 0;
if (hours > 40)
{
overtimeHours = hours - 40;
grossPay = (40 * payRate) + (overtimeHours * 1.5 * payRate);
}
else
grossPay = hours * payRate;
//endif
} //end of getGrossPay
double calcTotalGross(double grossPay, double totalGrossPay);
{
//declare variables
double totalGross = 0.0;
totalGross = totalGrossPay + grossPay;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
