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 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <iomanip>
using namespace std;
void getWages(long[], int[], float[], float[], int);
void displayWages(long, double, int);
int main()
{
const int size = 7;
long empId[size] = {5658845, 4520125, 7895122, 8777541,
8451277, 1302850, 7580489};
int hours[size];
float payRate[size], wages[size];
//get wages for each employee
getWages(empId, hours, payRate, wages, size);
return 0;
}
void getWages(long empId[], int hours[], float payRate[], float wages[], int size)
{
for (int index = 0; index <= size; index++)
{
cout << "Employee number: "<<empId[index] << endl;
cout << "Number of hours worked: ";
cin >> hours[index];
//eliminate negative numbers
while (hours[index] < 0)
{
cout << "Please enter a positive number." << endl;
cout << "Number of hours worked: ";
cin >> hours[index];
}
cout << "Employee pay rate: ";
cin>>payRate[index];
cout << endl;
wages[index] = hours[index] * payRate[index];
}
}
|