//Nathan Dominguez CSC5 Chapter 7, p. 445, #8
//
/*******************************************************************************
*
* Compute Payroll
*_______________________________________________________________________________
* This program will ask the user for their payrate and the number
* of hours that they worked, then calculate their wages. It will
* display the employee number and their associated gross wages.
*_______________________________________________________________________________
* Input
* payrate[count] : Employee's inputted payrate
* hours[count] : Employee's inputted hours
*
* Output
* wages[count] : gross wage for each employee
* empID[count] : employee ID
*
*************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare variables
const int numEmployee = 7; //CONST - number of employees
long empID[7] = {5658845, 4520125, 7895122, 8777541,
8451277, 1302850, 7580489}; //OUTPUT - employee ID
int hours[7]; //INPUT - employee hours
double payRate[7]; //INPUT - employee pay rate
double wages[7]; //OUTPUT - employee's gross wage
int count; //LOOP - counter
//
//loop program seven times
for (count = 0; count < numEmployee; count++)
{
cout << "Employee #" << empID[count] << ": " << endl;
cout << "Enter amount of hours worked: ";
cin >> hours[count];
cout << endl;
//
//input validation
if (hours[count] < 0)
{
cout << "Invalid, please try again." << endl;
cout << "Enter amount of hours worked: ";
cin >> hours[count];
cout << endl;
}
cout << "Enter pay rate: ";
cin >> payRate[count];
cout << endl;
//
//input validation
if (payRate[count] < 6.00)
{
cout << "Invalid, please try again. " << endl;
cout << "Enter pay rate: ";
cin >> payRate[count];
payRate[count] = payRate[count] / 100;
cout << endl;
}
//calculate gross wages
wages[count] = hours[count] * payRate[count];
cout << endl;
}
// output payroll
cout << "Payroll Report (Gross Wages): " << endl;
for (count = 0; count < numEmployee; count++)
{
cout << "#" << empID[count] << ": $" << wages[count] << endl;
}
return 0;
}