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

I was wondering what I wound need to add to my program to calculate a “pre-tax (

ID: 3586851 • Letter: I

Question

I was wondering what I wound need to add to my program to calculate a “pre-tax (before withholding tax) IRA (Individual Retirement Account)” deduction from gross pay using a function that returns the IRA deduction. The function must return the IRA deduction amount in dollars.

If gross pay is greater than $400 and less than $500, deduct 5%

If gross pay is $500 or more, deduct 10%

IRA contributions build a retirement account and lower gross pay for income tax purposes. This is why the reduction is made from gross pay prior to the tax withholding amount calculation. An example of the benefit is sow at the end of this document.

Modify the output to show the amount deducted for the IRA, and the modified gross pay as show below.

Code that I was using:

SAMPLE OUTPUT:

Some test data:

Hours of OT at Time and a half at Time and a half Hours of OT at Double Time at Double Rate Worked Dep Base Pay 550.00

Explanation / Answer

//Corrections done in finding overtimepay if loop, calculation of IRA amount

#include <iostream>

#include <iomanip> // std::setprecision

using namespace std;

//Function declarartion

double withHolding(double grossPay, int noOfDependents);

int main()

{

//setting the precision to two decimal places

std::cout << std::setprecision(2) << std::fixed;

//Declaring variables

int totHrsWorked, OtTimeAndHalf=0, OtTimeDouble=0, noOfDependents;

double hourlyPayRate, basePay, OtPayTimeAndHalf=0, OtPayDouble;

double grossPay, withHoldAmt, netpay,iraAmt=0,remAmt;

//Getting the input entered by the user

cout << "Total Hours Worked :";

cin >> totHrsWorked;

cout << "Hourly pay Rate :$";

cin >> hourlyPayRate;

cout << "No of Dependents :";

cin >> noOfDependents;

//calculating the base pay

if(totHrsWorked<=40)

basePay = totHrsWorked * hourlyPayRate;

else

basePay = 40 * hourlyPayRate;

//calculating the over time and half hours and pay

if (totHrsWorked > 40 && totHrsWorked <=50){

OtTimeAndHalf = totHrsWorked - 40;

OtPayTimeAndHalf = hourlyPayRate * 1.5;

}

//calculating the over time double hours and pay

if (totHrsWorked > 50){

OtTimeDouble = totHrsWorked - 50;

OtPayDouble = OtTimeDouble *2* hourlyPayRate;

}

//calculating the gross pay

grossPay = basePay + OtPayTimeAndHalf + OtPayDouble;

//calculating IRA amount

if(grossPay>400 && grossPay <500)

iraAmt = grossPay*0.05; //5% ira amount

if(grossPay>=500)

iraAmt = grossPay*0.1; //10% ira amount

remAmt = grossPay - iraAmt;

//calculating the withholding amount by calling the function

withHoldAmt = withHolding(remAmt, noOfDependents);

//calculating the net pay

netpay = remAmt - withHoldAmt;

//Displaying the output

cout << "Base Pay :$" << basePay << endl;

cout << "Overtime hours at time and half :" << OtTimeAndHalf << endl;

cout << "Overtime Pay at time and half :$" << OtPayTimeAndHalf << endl;

cout << "Overtime hours at double time :" << OtTimeDouble << endl;

cout << "Overtime pay at double time :$" << OtPayDouble << endl;

cout << "Gross pay :$" << grossPay << endl;

cout << "IRA deposit :$" << iraAmt << endl;

cout << "Tax Withholding amount : $" << withHoldAmt << endl;

cout << "NetPay :$" << netpay << endl;

return 0;

}

/* This function will calcualte the

* with hold amount based on the no of dependents

*/

double withHolding(double grossPay, int noOfDependents){

double withHold = 0.0;

if (noOfDependents == 0)

withHold = grossPay * 0.28;

else if (noOfDependents == 1)

withHold = grossPay * 0.20;

else if (noOfDependents == 2)

withHold = grossPay * 0.18;

else if (noOfDependents == 3)

withHold = grossPay * 0.15;

return withHold;

}

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