Payroll program accumulation and processing employees

My teacher is awful and we pretty much have a terrible book and some links he gave us. Doesn't help out or anything so I'm doing this on my own. I need some insight because I can't figure this one out.

I have a complete working program, but I need to integrate these things:

total number of employees processed
total gross pay
highest gross pay and the employee id
lowest gross pay and the employee id
average gross pay

It is not arrays as we have not gone that far and it is for another assignment.

I am thinking I have to use counters (++i or i++?) to do it and access the information but after hours and hours of research I am lost.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105`` ``````#include //allows program to output data to the screen #include using namespace std; //function main begins the payroll calculation program execution int main() { while (true) { //This repeats the program. You close console window manually by clicking "x". system ("CLS"); //this will clear the screen of any text from prior run std::cin.clear(); //this will clear any values remain in cin from prior run std::cout << "Welcome to gmsd's Payroll Calculator!\n\n"; // variable declarations int employeeID; // employee's ID number double hoursWorked; // number of hours employee worked float regularPay; // if hoursWorked <=40 then regular pay = hoursWorked * payRate double overtimePay; // if hoursWorked >40 then over times pay = 1.5 * (hoursWorked - 40) * payRate double federalTax; // amount of tax employee pays based on grossPay double payRate; // employee's pay rate double unionDues; // dues paid based on unionCode double grossPay; // gross pay is hoursWorked times payRate double netPay; // netPay is grossPay - (grossPay * federalTax) double paidTax; // paidTax is grossPay - netPay char unionCode; // employee's one character union code char A = 'A'; // unionCode A char B = 'B'; //unionCode B char C = 'C'; //unionCode C for (int x = 1; x <=5; x++) // loop program 5 times { std::cout << "\nEmployeeID: "; //request user input for EmployeeID std::cin >> employeeID; // read input from user into employeeID std::cout << "\nHours worked: "; // request user input for hoursWorked std::cin >> hoursWorked; // read input from user into hoursWorked while (hoursWorked <0 || hoursWorked > 60) // only allow input from 0-60 { std::cout << "\nError! You must enter a value between 0 and 60\n"; std::cout << "\nHours worked: "; std::cin >> hoursWorked; } std::cout << "\nPay rate: "; // request user input for payRate std::cin >> payRate; // read input from user into payrate while (payRate <7.50 || payRate > 45.00) //only allow input from 7.50 - 45.00 { std::cout << "\nError! You must enter a value between 7.50 and 45.00\n"; std::cout << "\nPay rate: "; std::cin >> payRate; } std::cout << "\nUnion code A, B, or C? "; // request user input for unionCode std::cin >> unionCode; // read input from user into unionCode while (unionCode !=A && unionCode !=B && unionCode !=C) //only allow input A, B, or C { std::cout << "\nError! Your code must be A, B, or C\n"; std::cout << "\nUnion code: "; std::cin >> unionCode; } regularPay = hoursWorked * payRate; // calculate regularPay overtimePay = 1.5 * (hoursWorked - 40) * payRate; // calculate overtimePay // qualifier for regularPay if (hoursWorked <= 40) regularPay = hoursWorked * payRate; overtimePay = 0; // qualifier for overtimePay if (hoursWorked > 40) regularPay = payRate * 40; overtimePay = (1.5 * payRate) * (hoursWorked - 40); // calculate unionDues switch (unionCode) { case 'A': unionDues = 25; break; case 'B': unionDues = 50; break; case 'C': unionDues = 75; break; } grossPay = regularPay + overtimePay; // calculate grossPay // qualifier for federalTax if ( grossPay > 2000 ) federalTax = .25; else if ( grossPay >= 1000 ) federalTax = .15; else federalTax = .1; netPay = grossPay - (grossPay * federalTax) - unionDues; // calculate netPay paidTax = grossPay * federalTax; // calculate paidTax std::cout << "\nIdentification Number: " << employeeID; //display employeeID std::cout << "\nHours Worked: " << hoursWorked; //display hoursWorked std::cout << "\nPay Rate: " << payRate; //display payRate std::cout << "\nUnion Code: " << unionCode; //display unionCode std::cout << fixed << setprecision(2); //format output to 2 decimal places std::cout << "\nRegular Pay: " << regularPay; //display regularPay std::cout << "\nOvertime Pay: " << overtimePay; // display overtimePay std::cout << "\nGross Pay: " << grossPay; // display grossPay std::cout << "\nFederal Tax: " << paidTax; // display federalTax std::cout << "\nUnion Dues: " << unionDues; // display unionDues std::cout << "\nNet Pay: " << netPay; // display netPay std::cout << "\n"; } std::cout << "\n\nBest payroll calculator in the whole world\n\n\n"; // Termination message system("PAUSE"); } return 0; } //end function main ``````
Topic archived. No new replies allowed.