Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Working With Functions in C++ 1. You currently employ several employees that are

ID: 3673168 • Letter: W

Question

Working With Functions in C++ 1. You currently employ several employees that are paid according to their status within your company. Employees can be categorized as Salaried Hourly or Contracted. Write a program that calculates the employee's weekly net pay based on the criteria below. Implement overloaded functions when calculating the gross pay and tax amount for each employee. Implement other functions as needed to construct a well-structured program. The program should continue to loop until the user indicates that they are done (you determine how). The total gross pay and tax amount for all employees should be displayed at the end of the program execution. Save the file as NetPay lastname.cpp Keep the following points in mind when creating your program Name your company and prepare a professional looking paystub for each employee. Output should be labeled, aligned, and formatted to 2 decimal places User will enter S, H, or C to indicate pay status Gross pay function calculations: Salaried employees - accepts yearly salary and returns calculated weekly amount by dividing amount by 52(weeks) Hourly employees - accepts hourly rate and number of hours worked. Returns calculated amount. Hours worked can include portion of hour. Employees working over 40 hours are paid 1.5 the hourly rate for hours over 40 o o o Contracted employees function accepts total amount of contract and number of weeks (integer value). Returns weekly amount by dividing amount by weeks

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

double grossPay(double yearlySalary){
   return yearlySalary / 52;
}
double grossPay(double hourlyrate, double numOfHours){
   if(numOfHours < 40) return hourlyrate * numOfHours;
   else return hourlyrate * 40 + 1.5 * hourlyrate * (numOfHours - 40);
}
double grossPay(double amountOfContract, int numOfWeeks){
   return amountOfContract / numOfWeeks;
}

double taxF(double grossPay){
   if(grossPay > 3000) return grossPay * 0.075;
   else{
       cout << "Enter the tax rate: ";
       double taxRate;
       cin >> taxRate;
       return grossPay * taxRate;
   }
}
double taxHourly(double grossPay){
   double taxRate;
   int choice;
   cout << "Enter 1 for the default tax rate(0.075): ";
   cin >> choice;
   if(choice == 1) taxRate = 0.075;
   else{
       cout << "Enter the tax rate: ";
       cin >> taxRate;
   }
   return grossPay * taxRate;
}

int main(){
   cout << fixed << setprecision(2);
   char payStatus;
   double gross = 0, tax = 0;
   while(true){
       do{
           cout << "Enter the pay status(0 to exit): ";
           cin >> payStatus;
           if(payStatus == '0'){
               return 0;
           }
           if(payStatus != 'S' && payStatus != 'H' && payStatus != 'C') cout << "Invalid input. ";
       }while(payStatus != 'S' && payStatus != 'H' && payStatus != 'C');
       double yearlySalary, hourlyrate, numOfHours, amountOfContract, numOfWeeks;
       switch(payStatus){
       case 'S':
           cout << "Enter the yearly salary: ";
           cin >> yearlySalary;
           cout << "Gross pay: " << grossPay(yearlySalary) << " ";
           cout << "Tax: " << taxF(grossPay(yearlySalary)) << " ";
           gross += grossPay(yearlySalary) ;
           tax += taxF(grossPay(yearlySalary));
           break;
       case 'H':
           cout << "Enter the hourly rate and number of hours: ";
           cin >> hourlyrate >> numOfHours;
           cout << "Gross pay: " << grossPay(hourlyrate, numOfHours) << " ";
           cout << "Tax: " << taxF(grossPay(yearlySalary)) << " ";
           gross += grossPay(hourlyrate, numOfHours) ;
           tax += taxF(grossPay(yearlySalary));
           break;
       case 'C':
           cout << "Enter the amount Of Contract & num Of Weeks: ";
           cin >> amountOfContract >> numOfWeeks;
           cout << "Gross pay: " << grossPay(amountOfContract, numOfWeeks) << " ";
           cout << "Tax: " << taxHourly(grossPay(yearlySalary)) << " ";
           gross += grossPay(amountOfContract, numOfWeeks) ;
           tax += taxHourly(grossPay(yearlySalary));          
           break;
       }
       cout << "Total gross salary: " << gross << " ";
       cout << "Total tax: " << tax << " ";
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote