ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 03 May 2017 My Price 9.00

Expand the Employee Payroll program

Looking for help with an assignment.  Basic C++ Programming, it's imperative it looks basic. Don't make it perfect, small errors are fine as long as it runs and works as it should.  I attached the code from the last assignment as each assignment is an extension of the previous.

These are the chapters the assignment is based on: 

Sorting: http://drebrahimi.com/chapter11.html

Inheritance: http://drebrahimi.com/chapter16.html 

Inheritance

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).

 

 

#include <iostream>
#include <iomanip>
using namespace std;
class payroll {
char employeessn[100];
char firstname[100];
char lastname[100];
int hoursworked, overtime, i;
double hourlyrate, overtimepay, overtimepaycalc, taxrate, regpay,
grosspay, taxamount, netpay;
void calculategrosspay();
void calculatetaxamount();
void calculatenetpay();
void calculateaveragepay();
static int numEmp;//memory needed for the array
public: void printheadings();//public method to be able to called in the main
method
void printdata();
static double averagepay;
static double sum;
public: payroll();
void printreport();
};
double payroll::averagepay = 0.0;
double payroll::sum = 0.0;
int payroll::numEmp = 0;
payroll::payroll() { //Gather the employee and payroll data
cout << "First name: " << endl;
cin >> firstname;
cout << "Last name: " << endl;
cin >> lastname;
cout << "First three numbers of employee's ssn: " << endl;
cin >> employeessn;
cout << "Please enter the amount of hours worked: " << endl;
cin >> hoursworked;
cout << "Please enter in the hourly wage: $" << endl;
cin >> hourlyrate;
}
void payroll::calculategrosspay() { //calculate pay according to type
grosspay = hoursworked * hourlyrate;
if (hoursworked>40)
{
overtime = hoursworked - 40;
regpay = 40 * hourlyrate;
overtimepaycalc = hourlyrate * 1.5;
overtimepay = overtime * overtimepaycalc;
grosspay = overtimepay + regpay;
}
else
{
overtime = 0;
regpay = 40 * hourlyrate;
overtimepaycalc = hourlyrate * 1.5;
overtimepay = overtime * overtimepaycalc;
grosspay = overtimepay + regpay;
}
};
void payroll::calculatetaxamount() {
if (grosspay >= 0) taxrate = .30;
taxamount = grosspay * taxrate;
}
void payroll::calculatenetpay() { netpay = grosspay - taxamount;
}
void payroll::calculateaveragepay() {
sum += netpay;
averagepay = (sum / numEmp);
}
void payroll::printheadings() {
cout << setw(45) << "-Amanda's Payroll Report-" << endl;
cout <<
"---------------------------------------------------------------------------------------------" << endl;
cout << "FirstName LastName
SSN
Hours Rate OThours OTpay
REGpay
GROSSpay
Taxes
NETpay" << endl;
cout << "======== =========
====
===
====
===
=====
======
=====
====
=====" << endl;
cout <<
"---------------------------------------------------------------------------------------------" << endl;
};
void payroll::printdata() {
cout << setprecision(2) << fixed << left;//setiosflags (ios::fixed |
ios::left);
cout << setw(9) << firstname << setw(9) << lastname << setw(4) << " " <<
employeessn << setw(3) << " " << hoursworked << setw(5) << " " << hourlyrate <<
setw(4) << "" << overtime << setw(3) << "" << overtimepay << setw(4) << " " <<
regpay << setw(5) << " " << grosspay << setw(5) << "" << taxamount << setw(3) <<
"" << netpay << endl << endl;
}
void payroll::printreport() {
numEmp++;
calculategrosspay();
calculatetaxamount();
calculatenetpay();
calculateaveragepay();
printdata();
}
int main(void) {
int numEmp;//memory needed for the array
cout << "Enter the number of Employees: ";
cin >> numEmp;
payroll *employee = new payroll[numEmp];//pointer used with the array
employee[0].printheadings();
for (int i = 0; i<numEmp; i++) {
employee[i].printreport();//to print each employee
}
cout << "Average Net Pay of all the Employees : $ " << payroll::averagepay
<< endl;
delete employee; //frees memory used by array
system("PAUSE");
return 0;
}

Answers

(11)
Status NEW Posted 03 May 2017 08:05 AM My Price 9.00

-----------

Attachments

file 1493800628-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)