Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objective Parallel Arrays Project This is a variation of programming challenge 7

ID: 3814471 • Letter: O

Question

Objective Parallel Arrays Project This is a variation of programming challenge 7.9 described in Gaddis on page 450 and 451 Write a program that uses several arrays. These are empID: an arrays of integers that will hole employee identification numbers. The user will enter the numbers. hours an array of integers to hole the number of hours worked by each employee. pay Rate: an array of doubles to hold the number of hours worked by each employee. wages: an array of seven doubles to hold each employee's gross wages. The program should set an upper bound (MAX SIZE for each of the arrays. It should then prompt the user for the number of employees. The program should then use a for loop to have the user enter the employeeID, the payRate, and the number of hours worked for each of the employees. The program will then calculate the pay for each of the employees following the current overtime rule that says that if an employee works more than 40 hours in a week they must receive 1.5 times their hourly payRate for the amount over forty hours The program will then calculate the total number of hours worked, the amount paid, and the average hourly wage that was paid The program should print the results in a formatted table. Each of the arrays, an integer variable for the number of employees, and the variables for the totals are to be in a class object. Input Validation: Do not accept negative values for any of the inputs. Fur- ther the hourly payRate must no less than the current minimum wage rate of $7.25

Explanation / Answer

#include<iostream>
using namespace std;

#define MAX_SIZE 500
#define OT 40

#define DAYS 7

class Employee

{

private:

int no_of_employee;

int empId[MAX_SIZE];

int hours[MAX_SIZE];

double payrate[MAX_SIZE];

double wages[DAYS];

int amountpaid[MAX_SIZE];

double avg_hourly_wage[MAX_SIZE];

int total_no_of_hours;
int total_wage_paid;

public:

int set_number_of_employee()

{

cout<<"Enter No of Employee;

cin>>no_of_employee;

if(no_of_employee>MAX_SIZE)
{

cout<<"Invalid Input";

return 0;

}

else
return 1;

}

int get_number_of_employee()

{

return no_of_employee;

}

int set_Emp_Data()

{

int i;
int flag=0;
for(i=0;i<no_of_employee;i++)
{

cout<<"Enter employee ID for Employee"<<i+1<<;

cin>>empID[i];

cout<<"enter payrate"<<endl;

cin>>payrate[i];

cout<<"Enter Number of hours worked"<<endl;

cin>>hours[i];

if(empId[i]<0||payrate[i]<7.5||hours[i]<0)

flag=1; break

}

return flag;

}

Void Calculate amout paid()

{

int i;

for(i=0;i<no_of_employee;i++)

{

if(hours[i]>OT)

{

amountpaid[i]=OT*payrate[i]+1.5*(hours-OT)

}

else

amountpaid[i]=hours*payrate[i];

}

}

void calculate_avg_hourly_wage()

{

int i;

for(i=0;i<no_of_employee;i++)
{

avg_hourly_wage[i]=amountpaid[i]/hours[i];

}

}

Void Calculate_total_no_of_hours()

{

int i; int s=0;
for(i=0;i<no_of_employee;i++)

{

s=s+hours[i];

}

total_no_of_hours=s;

}

Void set_total_wage_paid()

{

int i; double s=0;

for(i=0;i<no_of_employee;i++)

{

s=s+amountpaid[i];

}

total_wage_paid=s;

}

int calculate_avg_hourly_wage()

{

return= total_wage_paid/total_no_of_hours;

}

void print data()

{

int i;

for(i=0;i<no_of_employee;i++)

{

cout<<empid[i]<<amountpaid[i]<<avg_hourly_wage[i]<<endl;

}

}

int main()

{

Employee E;
E.set_number_of_employee();
if(!set_emp_data())

{

E.calculate_amount_paid();
E.calculate_avg_hourly_wage();
E.calculate_total_no_of_hours();
E.set_total_wage_paid();

}

cout<<E.calculate_avg_hourly_wage();

E.printdata();

}