I have tried to code this project but I am having trouble, I think I am close but no cigar. No this is not homework! I finished that and chose to attempt this one from my book on my own. Can anyone show me my issues and explain why I am not code compliant? Any help is greatly appreciated thank you in advance for advise:
Written directives from my book were as follows:
Design a program that computes pay for employees. Allow a user to continuously input employees’ names until an appropriate sentinel value is entered. Also input each employee’s hourly wage and hours worked. Compute each employee’s gross pay (hours times rate), withholding tax percentage (based on the accompanying table), withholding tax amount, and net pay (gross pay minus withholding tax). Display all the results for each employee. After the last employee has been entered, display the sum of all the hours worked, the total gross payroll, the total withholding for all employees, and the total net payroll.
Weekly Gross Pay Withholding Percent
(%)
0.00 – 200.00 10
200.01 – 350.00 14
350.01 – 500.00 18
500.01 – up 0 22
Code:
//Program: Payroll Report
//PayrollReport.cpp
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
string empName;
int *salary = 0;
int hrsWorked = 0;
int x = 0;
int grossPay = 0;
int withTax = 0;
int netPay = 0;
int totalGrossPay = 0;
int totalHrsWorked = 0;
int totalWithTax = 0;
int totalNetPay = 0;
string QUIT = "zzzz";
const int SIZE = 4;
double WITH_RATE[SIZE] = {0.10, 0.14, 0.18, 0.22};
double WITH_RANGE[SIZE] = {0, 200.01, 350.01, 500.01};
int main()
{
cout << "Enter an employee name or ", QUIT, " zzzz ";
cin >> empName;
while (empName != QUIT)
{
cout << "enter", empName, "'s hourly wage and hours worked";
cin >> *salary, hrsWorked;
grossPay = hrsWorked * *salary;
totalHrsWorked = totalHrsWorked + hrsWorked;
totalGrossPay = totalGrossPay + grossPay;
x = SIZE -1;
}
while (grossPay < WITH_RANGE[x]){
x = x -1;
}
withTax = (grossPay * WITH_RATE[x]);
endwhile
totalWithTax = totalWithTax + withTax;
netPay = grossPay - withTax;
totalNetPay = totalNetPay + netPay;
cout << empName, grossPay, WITH_RATE[x] * 100, withTax, netPay;
cout << "Enter an employee name or ", QUIT, " zzzz ";
cin >> empName;
}
endwhile
cout << totalHrsWorked, totalGrossPay, totalWithTax, totalNetPay;
return 0;
system("PAUSE");
}