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

Dear, // utilities.h (header file) #include <iostream> #include <iomanip> using

ID: 3635560 • Letter: D

Question

Dear,

// utilities.h (header file)


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

#define MANAGER_PAY 700.0
#define SUPERVISOR_PAY 600.0
#define EMPLOYEE_PAY 500.0

#define SINGLE_INS_RATE 0.02
#define SING_WITH_CHILD_INS_RATE 0.03
#define MARRIED_INS_RATE 0.04
#define MARRIED_WITH_CHILD_INS_RATE 0.05

#define MEDICAL_AMOUNT 100.0
#define SOCIAL_SECURITY_AMOUNT_RATE 0.05

// returns employee pay based on employee position
double getEmployeePay(char empPosition)
{
switch(empPosition)
{
case 'm': return MANAGER_PAY;
case 's': return SUPERVISOR_PAY;
case 'e': return EMPLOYEE_PAY;
}
}

// determines and return bonus of employee for given gross pay
double determineBonus(double grossPay)
{
if(grossPay >= 12000)
return 1000.0;
else if(grossPay <= 11999 && grossPay >= 9000)
return 600.0;
else
return 0;
}

// calcuates and return tax based on gross pay
double calculateTax(double grossPay)
{
if(grossPay >= 7000)
return grossPay * 0.15;
else if (grossPay <= 6999 && grossPay >= 4000)
return grossPay * 0.1;
else if (grossPay <= 3999 && grossPay >= 2000)
return grossPay * 0.05;
else
return 0;
}

// determines and return insurance rate
double determineInsuranceRate(int empInsurance)
{
switch(empInsurance)
{
case 1: return SINGLE_INS_RATE;
case 2: return SING_WITH_CHILD_INS_RATE;
case 3: return MARRIED_INS_RATE;
case 4: return MARRIED_WITH_CHILD_INS_RATE;
}
}

// displays the input values
void showInput(int eNumber, int eHours, int insType, char ePosition)
{
cout << endl << endl;
cout << setw(24) << right << "Employee Number: " << setw(8) << eNumber << endl;
cout << setw(24) << right << "Hours worked: " << setw(8) << eHours << endl;
cout << setw(24) << right << "Insurance type: " << setw(8) << insType << endl;
cout << setw(24) << right << "Position: " << setw(8) << ePosition << endl << endl;
}

// displays the calculated values
void showOutput(double gPay, double tPay, double insAmount, double ssAmount, double tDed, double nPay)
{
cout.setf(ios::floatfield, ios::fixed);
cout.precision(2);
cout << setw(25) << right << "Gross Pay: $" << setw(10) << gPay << endl;
cout << setw(25) << right << "Total Pay: $" << setw(10) << tPay << endl;
cout << setw(25) << right << "Insurance Amount: $" << setw(10) << insAmount << endl;
cout << setw(25) << right << "Medical Amount: $" << setw(10) << MEDICAL_AMOUNT << endl;
cout << setw(25) << right << "Social Security Amount: $" << setw(10) << ssAmount << endl;
cout << setw(25) << right << "Total Deductions: $" << setw(10) << tDed << endl;
cout << setw(25) << right << "Net Pay: $" << setw(10) << nPay << endl << endl;
}

next step

// main function (.cpp file)

#include "utilities.h"
#include <iostream>
using namespace std;

int main()
{
int empNumber, empHours, empInsurance;
char empPosition;

while(true)
{
system("cls"); // clears output screen

// reads employee number
cout << "Enter employee number (enter -1 to exit): ";
cin >> empNumber;

// check for sentinal value
if(empNumber == -1)
exit(0);

// inputs employee position
cout << "Enter employee position (m, s or e): ";
cin >> empPosition;
empPosition = tolower(empPosition);
// validates employee position
while(empPosition != 'm' && empPosition != 's' && empPosition != 'e')
{
cout << "invalid position, please re-enter" << endl;
cout << "m - manager s - supervisor e - employee ";
cout << "Enter employee position: ";
cin >> empPosition;
empPosition = tolower(empPosition);
}

// inputs employee working hours
cout << "Enter employee hours: ";
cin >> empHours;
// validates employee hours
while(empHours < 0)
{
cout << "Employee working hours should be positive, re-enter" << endl;
cout << "Enter employee hours: ";
cin >> empHours;
}

// inputs insurance type
cout << "Enter employee insurance type (1, 2, 3 or 4): ";
cin >> empInsurance;
// validates insurance type
while(empInsurance < 1 || empInsurance > 4)
{
cout << "invalid insurance type, please re enter" << endl;
cout << "1 - single 2 - single with children 3 - married 4 - married with children ";
cout << "Enter employee insurance type: ";
cin >> empInsurance;
}

// calculates employee pay
double grossPay = getEmployeePay(empPosition) * empHours;
double totalPay = grossPay + determineBonus(grossPay);
double insuranceAmount = grossPay * determineInsuranceRate(empInsurance);
double socialSecurityAmount = grossPay * SOCIAL_SECURITY_AMOUNT_RATE;
double totalDeductions = calculateTax(grossPay) + socialSecurityAmount + MEDICAL_AMOUNT + insuranceAmount;
double netPay = totalPay - totalDeductions;

// displays input data
showInput(empNumber, empHours, empInsurance, empPosition);
// displays calculated values
showOutput(grossPay, totalPay, insuranceAmount, socialSecurityAmount, totalDeductions, netPay);
system("pause");
} // end of while

return 0;
}

Explanation / Answer

Dear user,

start
Declare variables
   num MANAGER_PAY=700.0
   num SUPERVISOR_PAY=600.0
   num EMPLOYEE_PAY=500.0
   num SINGLE_INS_RATE=0.02
   num SING_WITH_CHILD_INS_RATE=0.03
   num MARRIED_INS_RATE=0.04
   num MARRIED_WITH_CHILD_INS_RATE=0.05
   num MEDICAL_AMOUNT=100.0
   num SOCIAL_SECURITY_AMOUNT_RATE=0.05
   num empNumber
   num empHours
   num empInsurance
   num grossPay
   num totalPay
   num insuranceAmount
   num totalDeductions
   num netPay
   string empPosition

double getEmployeePay(char empPosition);
double determineBonus(double grossPay);
double calculateTax(double grossPay);
double determineInsuranceRate(int empInsurance);
void showInput(int eNumber, int eHours, int insType, char ePosition);
void showOutput(double gPay, double tPay, double insAmount, double ssAmount, double tDed, double nPay);

output ""Enter employee number (enter -1 to exit): "
input empNumber

if(empNumber==-1)

   output "Enter employee position (m, s or e): "
   input empPostion
endif

   empPosition=tolower(empPosition)
   while(empPosition != 'm' && empPosition != 's' && empPosition != 'e')
       output "invalid position, please re-enter"
       output "m - manager s - supervisor e - employee "
       output "Enter employee position: ";
       input empPosition;
       empPosition = tolower(empPosition);
endwhile

   output "Enter employee hours:"
   input empHours;
   while(empHours < 0)
     output "Employee working hours should be positive, re-enter"
     output "Enter employee hours: "
     input empHours
   end while

   output "Enter employee insurance type (1, 2, 3 or 4): "
   input empInsurance;


   while(empInsurance < 1 || empInsurance > 4)
      output "invalid insurance type, please re enter"
      output "1 - single 2 - single with children 3 - married 4 - married with children ";
      output "Enter employee insurance type: ";
      output empInsurance;
   endwhile

grossPay = getEmployeePay(empPosition) * empHours;
totalPay = grossPay + determineBonus(grossPay);
insuranceAmount = grossPay * determineInsuranceRate(empInsurance);
socialSecurityAmount = grossPay * SOCIAL_SECURITY_AMOUNT_RATE;
totalDeductions = calculateTax(grossPay) + socialSecurityAmount + MEDICAL_AMOUNT + insuranceAmount;
netPay = totalPay - totalDeductions;
showInput(empNumber, empHours, empInsurance, empPosition);
showOutput(grossPay, totalPay, insuranceAmount, socialSecurityAmount, totalDeductions, netPay);

stop
-----------------------------------------------------------------------------------------------------
double getEmployeePay(char empPosition)
case 'm': return MANAGER_PAY;
case 's': return SUPERVISOR_PAY;
case 'e': return EMPLOYEE_PAY;
return

double determineBonus(double grossPay)
if(grossPay >= 12000)
   return 1000.0;
   else if(grossPay <= 11999 && grossPay >= 9000)
     return 600.0;
   else
return 0
double calculateTax(double grossPay)
if(grossPay >= 7000)
    return grossPay * 0.15;
else if (grossPay <= 6999 && grossPay >= 4000)
    return grossPay * 0.1;
   else if (grossPay <= 3999 && grossPay >= 2000)
   return grossPay * 0.05;
else
return 0

double determineInsuranceRate(int empInsurance)

    while(empInsurance)
    case 1: return SINGLE_INS_RATE;
    case 2: return SING_WITH_CHILD_INS_RATE;
    case 3: return MARRIED_INS_RATE;
    case 4: return MARRIED_WITH_CHILD_INS_RATE;
return

void showInput(int eNumber, int eHours, int insType, char ePosition)
output "Employee Number", eNumber
output "HoursWorked:",eHours
output "Insurance type:",insType
output " Position:",ePosition
return

void showOutput(double gPay, double tPay, double insAmount, double ssAmount, double tDed, double nPay)
output "Gross Pay: $",gPay
output "Total Pay: $", tPay
output "Insurance Amount: $", insAmount
output "Medical Amount: $", MEDICAL_AMOUNT
output "sOCIAL SECUIRTY AMOUNT: $", ssAmount
output "Total Decutions: $",tDed
output "Net Pay: $", nPay
return

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