Monday 20 February 2012

Simple Payroll Program



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;


//**********//


int main() {

const int empId = 7; //Number of employees
 int workers[empId] = {5658846, 4520125, 7895122,
        8777541, 8451277, 1302850,
        7580489}; //Employee ID numbers
int hours[empId]; //Holds hours worked
double payRate[empId]; //Holds pay rates

//Input the hours worked and the hourly pay rate.
cout << "Please enter the hours worked by " << empId
  << " employees and their\n"
  << "hourly pay rates.\n";
for (int index = 0; index < empId; index++)
{
 cout << "Please enter the hours worked by employee number " << (index+1) << ": ";
 cin >> hours[index];
 cout << "Please enter the pay rate for employee number " << (index+1) << ": ";
 cin >> payRate[index];
}

cout << "This is the gross pay for each employee:\n";
cout << fixed << showpoint << setprecision(2);

for (int index = 0; index < empId; index++)
{
 double grossPay = hours[index] * payRate[index];
 cout << "Employee #" << (index + 1);
 cout << ": earned $" << grossPay << endl << endl;
}
return 0;
}

No comments:

Post a Comment