So I'm back with another one of my professor's assignments. This time I'm supposed to calculate most of the information on a pay stub such as, base pay, overtime, taxes, etc. I'm currently reverse engineering my professor's code and came across this variable in a function that doesn't seem to have a value but is used as if it does, can someone please explain how the variable "gross" works?

also, can someone show me how to paste code correctly from visual studio? I'm new to it and don't really know how to use it.

C++:

```
#include <iostream>
#include <iomanip>
using namespace std;
/*
function that computes a pre-tax IRA (Individual Retirement Account) deduction from gross pay prior to computing the withholding amount
if gross pay is greater than $400 and less than $500, deduct 5%
if gross pay is $500 or more, deduct 10%
ira = gross * percent_deduction;
*/
double computeIRA(double gross);
/*
function that computes federal withholding
0 dependents - withhold 28% of gross pay
1 dependents - withhold 20% of gross pay
2 dependents - withhold 18% of gross pay
3 dependents or more - withhold 15% of gross pay
*/
double computeFedWithholding(int dependent, double gross);
int main()
{
//declaring variables
int hrs = 0, reg_hrs = 0, ot_hrs = 0, dt_hrs = 0, dependents = 0;
double payRate = 0, regPay = 0, otPay = 0, dtPay = 0, grossPay = 0, netPay, withholding;
const short unsigned FULL_TIME = 40;
const short unsigned OT_MAX = 50;
const double OT_RATE = 1.5;
const double DT_RATE = 2;
const double NO_DEPENDENTS = 0.28, SINGLE_DEPENDENT = 0.20, TWO_DEPENDENTS = 0.18, THREE_DEPENDENTS = 0.15;
bool isValid = false;
// Get pay rate
while (!isValid)
{
cout << "Enter your hourly rate of pay: ";
cin >> payRate;
isValid = payRate >= 0;
if (!isValid)
cout << "Error: the pay rate must be >= 0." << endl;
}
isValid = false; // reset the flag
// Get hours worked
/*
Note: some people get confused with line 73 so I show here any more explicit
*/
while (isValid == false)
{
cout << "Enter the number of hours worked: ";
cin >> hrs;
isValid = hrs >= 0;
if (!isValid)
cout << "Error: the number of hours must be >= 0." << endl;
}
isValid = false; // reset the flag
// Get hours worked
do
{
cout << "Enter the number of dependents: ";
cin >> dependents;
isValid = dependents >= 0;
if (!isValid)
cout << "Error: the number of dependents must be >= 0." << endl;
} while (isValid == false);
/*
NOTE: because we validate above we can rest assured that all calculation that follow should work-out
*/
// Compute DT hours
dt_hrs = hrs - OT_MAX;
/*
Compute OT hours
if we have double hours ot_hrs will be the difference between max OT and full-time (10)
else use the same calculation from last week
*/
ot_hrs = hrs - FULL_TIME;
if (dt_hrs > 0)
{
reg_hrs = FULL_TIME;
ot_hrs - FULL_TIME;
}
else if (ot_hrs > 0)
{
dt_hrs = 0;
reg_hrs = FULL_TIME;
}
else
{
dt_hrs = 0;
ot_hrs = 0;
reg_hrs = hrs;
}
//calculating the gross pay
regPay = reg_hrs * payRate;
otPay = ot_hrs * payRate * OT_RATE;
dtPay = dt_hrs * payRate * DT_RATE;
grossPay = regPay + otPay + dtPay;
// compute
double ira = computeIRA(gross);
// IRA deduction
double modifiedGross = gross - ira;
// calculate the withholding
withholding = computeFedWithholding(dependent, modifiedGross);
// calculate the net pay
netPay = modifiedGross - withholding;
//displaying to the user the number of hours they worked, their hourly pay rate, and the calculated gross pay
cout << endl << fixed << showpoint << setprecision(2);
cout << "Regular hours at $" << payRate << " = " << reg_hrs << endl;
cout << "Base pay at regular rate = $" << regPay << endl;
cout << "Overtime hours at time and a half = " << ot_hrs << endl;
cout << "Overtime pay at time and a half = $" << otPay << endl;
cout << "Overtime hours at double time = " << ot_hrs << endl;
cout << "Overtime pay at doulbe time = $" << otPay << endl;
cout << "Federal tax bracket with " << dependents << " dependents is " << setprecision(0) << noshowpoint << taxRate * 100 << "%" << endl;
cout << setprecision(2) << showpoint;
cout << "Gross pay = $" << grossPay << endl;
cout << "IRA contribution with " << grossPay << " in gross pay = " << ira << endl;
cout << "Modified Gross pay = $" << modifiedGross << endl;
cout << "Federal tax withholding with " << dependents << " dependents is $" << withholding << endl;
cout << "Net pay = $" << netPay << endl;
// display lab 5 specific display message
return 0;
}
double computeIRA(double gross)
{
double ira = 0;
if (gross > 400 && gross < 500)
{
ira = gross * 0.05;
}
else if (gross >= 500)
{
ira = gross * 0.10;
}
return ira;
}
/*
function that computes federal withholding
0 dependents - withhold 28% of gross pay
1 dependents - withhold 20% of gross pay
2 dependents - withhold 18% of gross pay
3 dependents or more - withhold 15% of gross pay
*/
double computeFedWithholding(int dependent, double gross)
{
double taxRate, withholding;
switch (dependents)
{
case 0:
taxRate = NO_DEPENDENTS;
break;
case 1:
taxRate = SINGLE_DEPENDENT;
break;
case 2:
taxRate = TWO_DEPENDENTS;
break;
default:
taxRate = THREE_DEPENDENTS;
}
withholding = grossPay * taxRate;
return withholding;
}
```