Question: Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects, inheritance for different classes

Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects, inheritance for different classes of employees, and polymorphism for salary computation. The 52 week yearly salary as well as number of overtime hours worked by a salary based employee is given). For salary based employees, to find the regular (gross) pay for a week, divide the salary by 52. To compute the overtime pay for a salary based employee, first find the hourly rate by dividing the gross pay by 40, and then compute overtime pay. For every employee, overtime pay, tax amount, and net pay must also be computed. In addition, the program should find the minimum and maximum net pay of all employees as well as sort the employees based on their net pay (ascending order).

I cannot get my code to work at all ugh.

#include #include #include

using namespace std; class payroll{ protected: string firstName, lastName; int employeeID, payStat; double hourlyRate, taxRate, hours, salary;

public: void setVariables(int empID, string fName, string lName, int stat, double rate, double hrs){ employeeID = empID; firstName = fName; lastName = lName; payStat = stat; if (payStat == 1){ hourlyRate = rate; } else { salary = rate; } hours = hrs; } public: virtual double calculateGrossPay() = 0; double calculateTaxAmount(){ double taxRate = .30; double taxAmount = calculateGrossPay() * taxRate; return taxAmount; } double calculateNetPay(){ double NetPay=calculateGrossPay()-calculateTaxAmount(); return NetPay; } };

class employeeSalary : public payroll{ public: double calculateGrossPay() { double regPay = (salary/52); hourlyRate =(regPay/40); double otPay, otHours; double grossPay; if (hours > 40) {otHours = (hours - 40); otPay = (otHours * hourlyRate); grossPay = (regPay + otPay); } else if (hours <= 40) {otHours = 0; otPay = 0; grossPay = regPay; } return grossPay; } }; class employeeHourly : public payroll{ public: double calculateGrossPay(){ double regPay = (40 * hourlyRate); double otPay, otHours; double grossPay; if (hours > 40){ otHours = (hours - 40); otPay = (otHours * hourlyRate * 1.5); grossPay = (regPay + otPay); } else { otHours = 0; otPay = 0; grossPay = regPay; } return grossPay; } //Payroll class }; void printHeader(){ cout<

int main(void){ int empID; double rate; double hrs; int N cout<<"Enter # of employees you want to process: "; int totalEmployeeCount; cin>>totalEmployeeCount; payroll * employee[100]; for (int employeeCounter = 0; employeeCounter < totalEmployeeCount; employeeCounter++){ cout<<"Is employee "<>stat; if (stat == 1){ cout<<"Instantiating an HOURLY employee object inherited from base class payroll..."<>empID; cout<<"Enter employee's first name: "; cin>>fName; cout<<"Enter employee's last name: ";cin>>lName; cout<<"Enter employee's hourly wage: "; cin>>rate; cout<<"Enter employee's hours for this week: "; cin>>hrs; employee[employeeCounter] = new employeeHourly(); employee[employeeCounter]->setVariables(empID, fName, lName, stat, rate, hrs); } else { cout<<"Instantiating a SALARY employee object inherited from base class payroll..."<calculateGrossPay()<calculateTaxAmount()<calculateNetPay()<display(); cout<<" details of minimum pay salary based employee is " ; employee[0]->display(); cout <<"the sorted list of salary based employees is "; for(i=0;idisplay(); cout<display(); cout<<" details of minimum pay hourly based employee is " ; employee1[0]->display(); cout <<"the sorted list of hourly based employees is "; for(i=0;idisplay(); cout<

void sort_hourly_based(hourly_based *employee[], int size){ int i,j,max; hourly_based *temp; for(i=0;inet>employee[j]->net) max=j; } temp=employee[i]; employee[i]=employee[max]; employee[max]=temp; //swap(employee[i],employee[max]); } }

void sort_salary_based(salary_based *employee[], int size){ int i,j,max; salary_based *temp; for(i=0;inet>employee[j]->net) max=j; } temp=employee[i]; employee[i]=employee[max]; employee[max]=temp; //swap1(employee[i],employee[max]); } } void swap(hourly_based *employee1, hourly_based *employee2){ hourly_based *temp; temp=employee1; employee1=employee2; employee2=temp; }

void swap1(salary_based *employee1, salary_based *employee2){ salary_based *temp; temp=employee1; employee1=employee2; employee2=temp; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!