Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help calculating the the gross pay for salaried employees. It should as simple as adding the OTP Over Time Pay and REGP Regular

I need help calculating the the gross pay for salaried employees. It should as simple as adding the OTP "Over Time Pay" and REGP "Regular Pay" but I can't seem to get it to display correctly. This is obviously throwing off my Net Pays for salaried employees. I'm including a copy of my input files, code and current output. Please Help !

//Input files

"hpayroll.dat"

1225 S Loni Smith 45 20 7995 s Tony Smith 50 20 8716 m Daniel Smith 35 30 1512 s Nico Smith 30 12 1513 M Anna Smith 42 24

"spayroll.dat"

1225 S John Madden 50000 5 7995 s Bill Thomas 35000 10 8716 m Tom Rogers 75000 15 1512 s Frank Rilli 42000 2 1513 M Janice Rossi 25000 12

//Code

#include #include #include #include #include

using namespace std;

class payroll { public: ifstream fin;

long int employeeid; char marital; string firstname, lastname; double hourlyrate, grosspay, netpay, taxrate, mtaxrate, taxamount, regpay, otpay; float sumOfNetPay; double count; int hoursworked, othours;

void computetaxrate(); void computemtaxrate(); void computenetpay();

// POLYMORPHISM virtual void computegp(); virtual void computeotp(); virtual void printheadings(); virtual void printdata(); virtual void printreport();

payroll(); ~payroll(); };

payroll::payroll() { fin.open("hpayroll.dat"); }//CONSTRUCTOR

payroll::~payroll() { fin.close(); }//DESTRUCTOR

void payroll::computeotp() { if (hoursworked > 40) othours = hoursworked - 40; else othours = 0; otpay = othours * (hourlyrate * 1.5); if (hoursworked

void payroll::computegp() { grosspay = (hoursworked * hourlyrate) + otpay; regpay = (grosspay - otpay); }//COMPUTE ALL THE GROSSPAYS

void payroll::computetaxrate() { if (grosspay > 1000) taxrate = 0.30; else if ((grosspay > 800) && (grosspay 500) && (grosspay = 0) && (grosspay

void payroll::computemtaxrate() { if (marital == 'S' || marital == 's') mtaxrate += 0.05; else if (marital == 'H' || marital == 'h') mtaxrate -= 0.05; else mtaxrate = taxrate; }//COMPUTE MARTIAL TAX RATES

void payroll::computenetpay() { taxamount = (grosspay * (taxrate + mtaxrate)); netpay = (grosspay - taxamount); sumOfNetPay += netpay; }//COMPUTE NET PAY AS WELL AS SUM OF NETPAYS

void payroll::printheadings() { cout

void payroll::printdata() { cout

void payroll::printreport() { int i = 0; printheadings(); while (fin >> employeeid >> marital >> firstname >> lastname >> hoursworked >> hourlyrate) { count++; computeotp(); computegp(); computetaxrate(); computemtaxrate(); computenetpay(); printdata(); i++; }//WHILE }//PRINT REPORT

class spayroll : public payroll { public: double salary52;

spayroll(){}; void update(long int, char, string, string, double, int); void printreport(); void computegp(); void computeotp(); void printdata(); void printheadings(); double get_netpay();

spayroll& operator = (const spayroll &obj) { employeeid = obj.employeeid; marital = obj.marital; firstname = obj.firstname; lastname = obj.lastname; salary52 = obj.salary52; hoursworked = obj.hoursworked; netpay = obj.netpay; othours = obj.othours; hourlyrate = obj.hourlyrate; grosspay = obj.grosspay; netpay = obj.netpay; taxrate = obj.taxrate; mtaxrate = obj.mtaxrate; taxamount = obj.taxamount; regpay = obj.regpay; otpay = obj.otpay; sumOfNetPay = obj.sumOfNetPay; count = obj.count; } };

void spayroll::update(long int eid, char ms, string f, string l, double s52, int h) { employeeid = eid; marital = ms; firstname = f; lastname = l; salary52 = s52; hoursworked = h; }

// COMPUTE GROSS PAY FOR SALARY EMPLOYEE void spayroll::computegp(){ grosspay = regpay = salary52/52; hourlyrate = grosspay / 40; }

void spayroll::computeotp() { otpay = hourlyrate * hoursworked; }

void spayroll::printheadings() { cout

void spayroll::printdata() { cout

void spayroll::printreport() { computegp(); computeotp(); computetaxrate(); computemtaxrate(); computenetpay(); printdata(); }//PRINT REPORT

double spayroll::get_netpay() { return netpay; }

// SELECTION SORT void selsort(spayroll a[], int n) { int i,j,loc; double min; spayroll temp; for(i=0;i a[j].get_netpay()) { min = a[j].get_netpay(); loc = j; } } temp = a[i]; a[i] = a[loc]; a[loc] = temp; } }<-1>

int main() { payroll employee; cout > employeeid >> marital >> firstname >> lastname >> salary52 >> hoursworked) { emp[i].update(employeeid, marital, firstname, lastname, salary52, hoursworked); i++; } emp[0].printheadings(); for (int i=0;i _max) _max = cur; } cout

cout

emp[0].printheadings(); for (int i=0;i

//Output

image text in transcribed

FOR HOURLY BASED EMPLOYEES PAYROLL REPORT EMP ID MARTIAL STAT FIRST NAME LAST NAME HW HR OTH OTP REGP GROSS TAX NET 1225 Smith 45 20 150 900 1050 367.5 682.5 Loni Smith 7995 Tony 50 20 10 300 1000 1300 520 780 Daniel Smith 8716 35 30 0 1050 1050 630 420 Nico Smith 1512 30 12 0 360 360 126 234 1513 Smith 42 24 2 72 1008 1080 648 432 Anna Sum of Net Pay: 2548.5 Average Net Pay: 509.7 FOR SALARY BASED EMPLOYEES PAYROLL REPORT EMP ID MARTIAL STAT FIRST NAME LAST NAME HR OTH OTP REGP GROSS TAX NET Madden 24.0385 1225 John 120.192 961. 538 961.538 240.385 721.154 Bill Thomas 7995 16.8269 10 168.269 673.077 673.077 100.962 572.115 8716 Rogers 36.0577 15 540.865 1442.31 1442.31 865.385 576.923 Frank Rill 20.1923 1512 40.3846 807.692 807.692 201.923 605.769 1513 Janice Rossi 12.0192 12 144.231 480.769 480.769 0 480.769 Minimum netpay of all employees is 480.769 Maximum netpay of all employees is 721.154 SORTED EMPLOYEES BASED ON THEIR NET PAY PAYROLL REPORT EMP ID MARTIAL STAT FIRST NAME LAST NAME TAX HR OTH OTP REGP GROSS NET Janice 480.769 1513 Rossi 12.0192 12 144.231 480.769 480.769 Bill Thomas 7995 16.8269 10 168.269 673.077 673.077 100.962 572.115 Tom Rogers 36.0577 15 540.865 1442.31 1442 865.385 576.923 1512 Frank Rilli 20.1923 40.3846 807.692 807.692 201.923 605.769 John Madden 24.0385 1225 120.192 961. 538 961.538 240.385 721.154 Process exited after 0.04471 seconds with return value 0 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions

Question

Identify and control your anxieties

Answered: 1 week ago

Question

Understanding and Addressing Anxiety

Answered: 1 week ago