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

Complete the following C++ program by including the definition for the function

ID: 3816036 • Letter: C

Question

Complete the following C++ program by including the definition for the function named calcNetPay that returns weekly pay in currency format.

The function has the formal parameter hours to pass the value of the number of hours worked in a week and the formal parameter rate to pass the value of the hourly rate.

*;Deductions:

o Assume a FIT rate of 10%

o Assume a SS tax rate of 6.2%

o Assume a Medicare tax rate of 1.45%

o Assume No deductions for Health or Dental

o Do not worry about adding an Overtime handling element to the function at this time.

*;Do indeed display the number in currency format ($ in front, and precision of 2 decimal places after the decimal)

*;Add 2 additional function calls to the program passing the following parameters in the main function’s body (in a cout statement):

o hours: 25, rate: 7.95

o hours: 39, rate: 65.78

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

double calcNetPay(double, double);// function prototype

int main ( )
{

double clockedHours = 32.5, hourlyRate = 55.25;
cout << calcNetPay (clockedHours, hourlyRate) << endl;

system("pause");

return 0;

}


double calcNetPay(double hours, double rate)
{ // complete the function definition

//return the weekly pay number (variable) here
return 0.0;
}

Explanation / Answer

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

double calcNetPay(double, double);// function prototype


int main ( )
{

double clockedHours = 32.5, hourlyRate = 55.25;
cout << "$"<<fixed<<setprecision(2)<<calcNetPay (clockedHours, hourlyRate) << endl;

//system("pause");

return 0;

}

double calcNetPay(double hours, double rate)
{ // complete the function definition

double FITRate = 10;
double SSTax =6.2;
double MedicareTax = 1.45;
double weeklypay = hours * rate;
double FITRateAmt = (weeklypay * FITRate)/100;
double SSTaxAmt = (weeklypay * SSTax)/100;
double MedicareTaxAmt = (weeklypay * MedicareTax)/100;
double totalDeductions = MedicareTaxAmt + SSTaxAmt+FITRateAmt;
weeklypay = weeklypay - totalDeductions;
//return the weekly pay number (variable) here
return weeklypay;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

$1478.70