Question: Using DEVC++ Expand the Employee Payroll program to include hourly based and salary based employees. This phase uses an array of employee objects , inheritance
Using DEVC++
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).
The CODE I am using
#include
class sal { public: string empName; double hourlyRate,hoursWorked; double overTimePay(double hoursWorked,double hourlyRate); double regularPay(double hoursWorked,double hourlyRate); double calTax(double totAmt); };
double sal::overTimePay(double hoursWorked,double hourlyRate) { double oTPay=0.0; if(hoursWorked>40) { oTPay=(hoursWorked-40)*1.5*hourlyRate; } return oTPay; } double sal::regularPay(double hoursWorked,double hourlyRate) { double grosspay=0.0; if(hoursWorked<=40) { grosspay=hoursWorked*hourlyRate; } else { grosspay=40*hourlyRate; } return grosspay; } double sal::calTax(double totAmt) { return totAmt * TAX_RATE; }
int main() { sal s[10]; string empName; int i=0; double ot,grosspay,netPay,totAmt,tax,sum,hourlyRate,hoursWorked; ifstream infile("employee.in");
while(infile>>empName>>hoursWorked>>hourlyRate) { s[i].empName=empName; s[i].hourlyRate=hourlyRate; s[i].hoursWorked=hoursWorked; cout<<"Employee Name :"<
cout<<"Average Net Pay of All Employees : $ "< cin.get(); } NO clue what to put for my text (infile) to get a proper output that covers what my professor is askinf for. The code needs to cover all of the things he is asking for although not be too complicated seeing as this is an introductory course.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
