Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employees net pay. //I need to

Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employees net pay.

//I need to use an EXSEL sort in order to combine the selection and Exchange sorts for my program. I currently have a selection sort in there. Please help me with replacing this with the EXSEL sort.

//My input files:

image text in transcribedimage text in transcribed

//My current code with the sel sort. Please help me replace this with an EXSEL sort.

#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(){ regpay = salary52/52; hourlyrate = regpay / 40; grosspay = regpay + hourlyrate * hoursworked; }

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

//Current Output

image text in transcribed

) hpayroll.dat-Notepad File Edit Format View Help 1225 S Saverio Smith 45 20 7995 s Michelle Smith 50 20 8716 m Santino Smith 35 30 1512 s Nicholas Smith 30 12 1513 M Julianna Smith 42 24

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions