#include <iostream>
#include <iomanip>
using namespace std;
void employeeHours(int hours[], int NUM_EMPLOYEES[], int index);
void displayHoursErrorMessage();
void employePayRate(double payRate[], int NUM_EMPLOYEES[],int index);
void displayPayrateErrorMessage();
void grossPay(int hours[],double payRate[],int NUM_EMPLOYEES[], int index);
const int NUM_EMPLOYEES=7;
int main()
{
int NUM_EMPLOYEES[ ]= {5658845, 4520125, 7895122, 8777541, 8451277,1302850,7580489}; //numbers of employees double sales[] = {12.25, 32.50, 16.90, 23, 45.68};
int hours[7]; //holds hours worked
double payRate[7]; //holds pay rates
cout<<'\t'<<"***Enter the hours worked by the employees and the hourly pay rate***"<<endl;
cout<<'\n'<<endl;
for (int index=0;index<7;index++)
{
employeeHours(hours, NUM_EMPLOYEES, index);
while(hours[index]<=0)
{
displayHoursErrorMessage();
employeeHours(hours, NUM_EMPLOYEES, index);
}
employePayRate(payRate, NUM_EMPLOYEES,index);
while(payRate[index]<6)
{
//cout<<'\n'<<endl;
displayPayrateErrorMessage();
employePayRate(payRate, NUM_EMPLOYEES,index);
}
}
cout<<"Here is the gross pay for each employee:\n";
cout<<fixed<<showpoint<<setprecision(2);
for(int index=0;index < 7;index++)
{
grossPay(hours, payRate,NUM_EMPLOYEES, index);
}
system("pause");
return 0;
}
void employeeHours(int hours[], int NUM_EMPLOYEES[],int index)
{
cout<<(index+1)<<".""Hours worked by employee ID."<<NUM_EMPLOYEES[index]<<":";
cin>>hours[index];
}
void displayHoursErrorMessage()
{
cout<<'\t'<<'\t'<<"*Please Hours Worked can't be less than 0*"<<endl;
cout<<'\n'<<endl;
}
void employePayRate(double payRate[], int NUM_EMPLOYEES[],int index)
{
cout<<(index+1)<<".Please enter the hourly pay rate for employee ID."<<NUM_EMPLOYEES[index ]<<":";
cin>>payRate[index];
}
void displayPayrateErrorMessage()
{
cout<<'\t'<<'\t'<<"*Please Pay Rate can't be less than $6 per hour.*"<<endl;
cout<<'\n'<<endl;
}
void grossPay(int hours[],double payRate[],int NUM_EMPLOYEES[], int index)
{
double grossPay= hours[index]*payRate[index];
cout<<"Employee ID:"<<NUM_EMPLOYEES[index];
cout<<" Gross Pay: $" << grossPay<<endl;
}
No comments:
Post a Comment