Question: Complete the missing segments of the code classes and operator overloading.txt to calculate salary for employees. You are free to modify the codes where necessary.

Complete the missing segments of the code classes and operator overloading.txt to calculate salary for employees. You are free to modify the codes where necessary. However, it is important that you keep the structure and program flow. Also, ensure that the entire program works.

Use the information provided in the spreadsheets (in code ) to calculate employees salary and print the paystub. The information on each paystub should contain: ID.#, First Name, Last Name, Earnings, Deductions, NetPay, DedYTD and NetYTD.

HINT :

Full-TIme (Annual) Calculation: For a full-time salaried employee that makes $56,000 annually. The pay is monthly (12 pay periods in a year). Determining the employees pay is a simple calculation and based on the business pay schedule. It should look like this: $56,000 / 12 = $4,666.67. This is the employees gross pay (earnings). 20% flat tax is applied to the above earnings. Part-Time Calculation:

For a part-time hourly employee that makes $15 an hour. The pay is simply: Part-time employees gross pay (earnings) = $15 x (Expected hours to work per day) x (Days worked) 20% flat tax is applied to the above earnings as well. Note: Part-time staff with the highest hours worked (workday*hours) gets a bonus (10% of gross) in addition to the netPay.

CODE ( copy and paste )

/* Program Data ID. # C/Type First Name Last Name Rate Daily Hours Days Worked Earnings Ded. YTD Net YTD 101 F Michael Smith 5000 10000 40000 102 P Maria Rodriguez 25 10 14 7000 28000 103 P James Robert 25 8 12 4800 19200 104 P Kenny Mercedes 25 12 12 7200 28800 105 F Kyndra Hernandez 4000 8000 32000 */ //Note: tax and bonus are in percentage that 20% and 10% respectively /* Format for Final Report ID. # C/Type First Name Last Name Rate Hours Earnings Deductions NetPay Ded. YTD Net YTD 101 F Michael Smith A D=A * Tax(20%) G=A - D J=5000+D M=40000+G 105 F Kyndra Hernandez B E=B * Tax(20%) H=A - E K=4000+E N=32000+H Full-Time Sub-Total C=A+B F=D+E I=G + H L=J + K O=M + N 102 P Maria Rodriguez 20 P=Hours*Day T=P*Rate X=T * Tax(20%) AB=T - X AF=7000 + X AJ=28000 + AB 103 P James Robert 25 Q=Hours*Day U=Q*Rate Y=U * Tax(20%) AC=U - Y AG=4800 + Y AK=19200 + AC 104 P Kenny Mercedes 22 R=Hours*Day V=R*Rate Z=V * Tax(20%) AD=V - Z AH=7200 + Z AL=28800 + AD Part-Time Sub-Total S=P + Q + R W=T + U + V AA=X + Y + Z AE=AB+AC+AD AI=AF+AG+AH AM=AJ+AK+AL Total Summary AN=C + W AO=F + AA AP=I + AE AQ=L + AI AR=O + AM */ #include  #include  #include  #include  //#include  using namespace std; const float tax = 20; const int bonus = 10; class EmployeeData{ protected: float gross; float deductions; float netPay; float netYTD; float dedYTD; public: int idNum; char fName[15]; char lName[15]; char contract; EmployeeData(){ //Feel free to add anything in here. } void CalculateGross(){ cout << "Inside EmployeeData? Wrong...Look again at the pointer.." << endl; } }; class FullTime : public EmployeeData{ protected: float earnings; public: FullTime(int ivar=0, string fvar=" ", string lvar=" ", char cvar=' ', float dyvar=0, float nyvar=0){ idNum = ivar; strcpy(fName, fvar.c_str()); strcpy(lName, lvar.c_str()); contract = cvar; earnings = 0; gross = 0; deductions = 0; netPay = 0; dedYTD = dyvar; netYTD = nyvar; } void CalculateGross(){ gross = earnings; } }; class PartTime : public EmployeeData{ protected: float payRate; int hours; int workDays; public: PartTime(int ivar=0, string fvar=" ", string lvar=" ", char cvar=' ', float dyvar=0, float nyvar=0){ idNum = ivar; strcpy(fName, fvar.c_str()); strcpy(lName, lvar.c_str()); contract = cvar; payRate = 0; hours = 0; workDays = 0; gross = 0; deductions = 0; netPay = 0; dedYTD = dyvar; netYTD = nyvar; //cout << "PartTime constructor..." << endl; } void CalculateGross(){ //cout << "Inside PartTime......" << endl; gross = payRate * hours * workDays; } }; //Note: //gross = earnings (for FullTime) //gross = payRate * hours * workDays (for PartTime) //deductions = gross * tax/100 //netPay = gross - deductions //netPay = netPay + (gross * (bonus/100)) (for only the PartTime object with the highest hours worked - hours * workDays) //Use the spreadsheet for more information int main(){ EmployeeData *objptr; FullTime ftobj1(101, "Michael", "Smith", 'F', 10000, 40000); PartTime ptobj1(102, "Maria", "Rodriguez", 'P', 7000, 28000); FullTime ftobj2(105, "Kyndra", "Hernandez", 'F', 8000, 32000); PartTime ptobj2(103, "James", "Robert", 'P', 4800, 19200); PartTime ptobj3(104, "Kenny", "Mercedes", 'P', 7200, 32000); //Use the input operator to enter hour and earnings //for FullTime objects, input required is: earnings //for PartTime objects, input required are: payRate, hours and workDays cin >> ftobj1; cin >> ftobj2; cin >> ptobj1; cin >> ptobj2; cin >> ptobj3; //Calculate gross income using member function already given in the classes and the EmployeeData pointer (objptr) //for FullTime objects - objptr->CalculateGross() must run the CalculateGross() in FullTime class and not another class //for PartTime objects - likewise objptr->CalculateGross() must run the CalculateGross() in PartTime class. objptr = &ftobj1; objptr->CalculateGross(); objptr = &ftobj2; objptr->CalculateGross(); objptr = &ptobj1; objptr->CalculateGross(); objptr = &ptobj2; objptr->CalculateGross(); objptr = &ptobj3; objptr->CalculateGross(); //Calculate deduction and netPay using the substraction assignment operator overloading //deductions = gross * tax/100; netPay = gross - netPay; ftobj1 -= tax; ftobj2 -= tax; ptobj1 -= tax; ptobj2 -= tax; ptobj3 -= tax; //Use (++) Prefix operator to update netYTP with netPay to reflect YTD-netPay //netYTD = netYTD + netPay; ++ftobj1; ++ftobj2; ++ptobj1; ++ptobj2; ++ptobj3; //Use Postfix (++) operator to update dedYTP with deductions to reflect total deductions to date in the financial year //dedYTD = dedYTD + deductions; ftobj1++; ftobj2++; ptobj1++; ptobj2++; ptobj3++; //Use the relational operator overloading to find Part-time staff with the highest worked hours (workday*hours) \ and use function call () operator to add bonus (10% of gross) to the netPay //to add bonus ==> netPay = netPay + (gross * bonus/100) if (ptobj1 > ptobj2){ if (ptobj1 > ptobj3){ ptobj1(bonus); //netPay = netPay + (gross * bonus/100) } } else{ if (ptobj2 > ptobj3){ ptobj2(bonus); //netPay = netPay + (gross * bonus/100) } else{ ptobj3(bonus); //netPay = netPay + (gross * bonus/100) } } //Declared for data summary manipulations FullTime totalftobj; PartTime totalptobj; PartTime totalptobj1; PartTime totalptobj2; //First use assignment operator to assign ptobj1 to totalptobj1 because you can pass more than two arguments //Attributes of interest for the summary report are: gross, deductions, netPay, netYTD, DedYTD totalptobj1 = ptobj1; //Use the + operator to sum the Deductions, netPay, DedYTD and netYTD for each group totalptobj2 = ptobj2 + ptobj3; totalptobj = totalptobj1 + totalptobj2; totalftobj = ftobj1 + ftobj2; //Use output operator to display/print for example: cout << ftobj1 << endl; cout << "ID. # First Name Last Name Earnings Deductions NetPay Ded.YTD Net YTD "<< endl; cout << ftobj1 << endl; cout << ftobj2 << endl; // and continue as required. 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!