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

C++

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'm in over my head here, class is moving too fast for me, don't really know what I'm reading. I seen a few posts on here for this exact question but its asking for a file that isn't part of the answer, so I dont know if that code is even working.

This was my last code for this project,

----------------------------------------------

#include "stdafx.h"

#include

#include

#include

#include

using namespace std;

class payroll

{

ifstream fin;

char employeeid[15];

char employeename[20];

char maritalstatus;

int hoursworked, overtime;

double hourlyrate, overtimepay, regularpay, grosspay, taxrate, taxamount, netpay, sum=0;

void calculategrosspay();

void calculatetax();

void calculatenetpay();

void printheadings();

void printdata();

public:payroll();

~payroll();

void printreport();

};

payroll::payroll() {

fin.open("payroll.dat.txt");

}//constructor

payroll::~payroll() {

fin.close();

}//Destructor

void payroll::calculategrosspay() {

if (hoursworked > 40) {

overtime = hoursworked - 40;

regularpay = hoursworked*hourlyrate;

overtimepay = overtime*(hourlyrate *1.5);

grosspay = regularpay + overtimepay;

}//if

else grosspay = hoursworked *hourlyrate;

}//calculate grosspay

void payroll::calculatetax() {

taxrate = .30;

if (maritalstatus == 'S' || maritalstatus == 's')

taxrate = taxrate + .05;

taxamount = grosspay*taxrate;

}//calculate tax

void payroll::calculatenetpay() {

netpay = grosspay - taxamount; //cacluate netpay

}

void payroll::printheadings() {

cout << setw(45) << "-Payroll Report-" << endl;

cout << "-----------------------------------------------------------------------" << endl;

cout << "NAME ID HW OT RT-PAY OT-PAY GROSS TAX NETPAY" << endl;

cout << "-----------------------------------------------------------------------" << endl;

}//print headings

void payroll::printdata() {

cout << setprecision(2) << setiosflags(ios::fixed | ios::showpoint);

cout << setw(6) << employeename << setw(12) << employeeid << setw(4) << hoursworked << setw(3) << overtime << setw(8) << regularpay << setw(8) << overtimepay << setw(8) << grosspay << setw(8) << taxamount << setw(8) << netpay << endl;

}//printdata

void payroll::printreport() {

int i = 0;

printheadings();

while (fin >> employeename >> employeeid >> maritalstatus >> hoursworked >> hourlyrate) {

calculategrosspay();

calculatetax();

calculatenetpay();

printdata();

i++;

sum += netpay;

}//while

cout << "The Sum of the company is " << sum << endl;

cout << "Average net pay for " << i << " employees is " << sum / i << endl;

}//printreport

int main()

{

payroll employee;

employee.printreport();

system("pause");

return 0;

}

--------------------------------

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!