// Saliha Babar CS1A Chapter 7, Page 445, #8
//
/***************************************************************************
* DISPLAY PAYROLL REPORT
* ________________________________________________________________________
* This program accepts hours worked and pay rate(dollar per hour) for 7
* employees. This program then, calculates the wages for each employee and
* display a payroll report.
*
* Formula related to this program
* wages = hours * payRate
* __________________________________________________________________________
* INPUT
* hours : hours worked by each employee
* payRate : pay rate for each employee
*
* OUTPUT
* wages : wages for each employee
* *************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
const int NUM_EMPLOYEES=7;
long int empId[NUM_EMPLOYEES] = { 5658845, 4520125, 7895122, 8777541,
8451277, 1302850, 7580489 };
int hours [NUM_EMPLOYEES]; // INPUT - hours worked by each employee
double payRate [NUM_EMPLOYEES]; // INPUT - pay rate of each employee
double wages[NUM_EMPLOYEES]; // OUTPUT - wages of each employee
for (int i = 0; i < NUM_EMPLOYEES ; i++)
{
cout << "Enter hours worked by employee #" << empId[i];
cin >> hours[i];
while (hours[i] < 0)
{
cout << "Only enter positive values.\n";
cin >> hours[i];
}
cout << "\nEnter the pay rate per hour (in $) for employee #" << empId[i];
cin >> payRate[i];
while (payRate [i] < 6.00)
{
cout << "Only enter pay rate that is greater than 6.00$\n";
cin >> payRate[i];
}
cout << endl << endl;
}
// Display the output
cout << "Employee Id\t\tHours Worked\tPay Rate($)\tWages($)\n";
cout << "___________________________________________________\n";
for ( int i = 0; i < NUM_EMPLOYEES ; i++ )
{
wages[i]= hours[i] * payRate[i];
cout << setw(11) <<empId[i];
cout << setw(16) << hours[i];
cout << fixed << setprecision(2);
cout << setw(14) << payRate[i];
cout << setw(10) << wages[i] << endl;
}
return 0;
}