C++:Problem16

Problem:
A company manager wants to determine the gross pay for each of his employees in a particular division. Also, the total payroll

Ask the company manager how many employees in a division?
Ask what each employee’s ID is?
Ask how many hours each employee worked per week?
Ask the amount hourly pay each employee earns?

Find the gross pay for each employees.
Find the total payroll for the division


Display the output below

Objective:
multi-parallel arrays

Display:
How many employee in the division: 3

What is the ID of employee 1 :3333
What is the hours worked in a week :55
What is the employee's hourly earnings: $10

What is the ID of employee 2 :3343
What is the hours worked in a week :33
What is the employee's hourly earnings: $13

What is the ID of employee 3 :3232
What is the hours worked in a week :40
What is the employee's hourly earnings: $16

Division: Automobile Wheels
Number of employees: 3
Total payroll for division: $1619

Employee ID Gross Pay

3333 $550
3343 $429
3232 $640

Code:
#include
#include
using namespace std;


void asking(int ID[],int hour[], int rate[], int size);
//purpose: To store the id, hours, rate in array to pass them to the display function.
//precondition:size of the division and the id, hours and the rate for each employee.
//postcondition: none
void display(int ID[], int hour[], int rate[], int size);
//purpose: to find the sum and the pay gross.
//precondition: none.
//postcondition: none.

int main ()
{
int const Max = 20;
int ID[Max];
int hour[Max];
int rate[Max];
int number;

//decimal format
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout << "How many employee in the division: ";
cin >> number;
cout << endl;
asking(ID,hour,rate,number);
display(ID,hour,rate,number);

return 0;
}

void asking(int ID[],int hour[], int rate[], int size)
{
int i;
for (i=0; i< size; i++)
{
cout << "What is the ID of employee "< cin >> ID[i];
cout << "What is the hours worked in a week :";
cin >> hour[i];
cout << "What is the employee's hourly earnings: $";
cin >> rate[i];
cout << endl;
}
}


void display(int ID[], int hour[], int rate[], int size)
{
int j;
int sum=0;
for (j=0; j sum = sum + hour[j] * rate[j];

cout << "Division: Automobile Wheels"< cout << "Number of employees: " << size << endl;
cout << "Total payroll for division: $"<< sum << endl << endl;
cout << "Employee ID"<< setw(15) << "Gross Pay" << endl << endl;

for (j=0; jcout << ID[j] << setw(16) << "$"<< hour[j] * rate[j] << endl;

}