Question #46130

Write a program to calculate a person's net pay after subtracting federal income tax. The program should ask the user to enter the person's name, social security number, gross pay, and number of dependents. The program should first determine the tax rate according to the following schedule.

Weekly Income Tax Rate

0.00–300.00 0.085
300.01–500.00 0.120
500.01–1000.00 0.185
1000.01 and over 0.220

Use a function Tax_Rate() to determine the schedule. Pass the gross pay to
Tax_Rate() and have the function return the rate.
Next,use the function Calc_Fed_Tax() to calculate the federal tax.The first ar-
gument should be the address of the gross income.The second argument should
be the address of the tax rate (as returned by Tax_Rate()).The third argument
should be the address of the number of dependents.The amount of the federal
tax should be returned in the target of the fourth argument.
Finally, the program should calculate the net pay by subtracting the federal tax
from the gross income.The program should display the person’s name,social se-
curity number,gross pay,number of dependents,federal tax,and net pay.
1

Expert's answer

2014-09-16T07:07:07-0400

Answer on Question #46130, Management, Other

Problem:

Write a program to calculate a person's net pay after subtracting federal income tax. The program should ask the user to enter the person's name, social security number, gross pay, and number of dependents. The program should first determine the tax rate according to the following schedule.

Weekly Income Tax Rate

0.00–300.00 0.085

300.01–500.00 0.120

500.01–1000.00 0.185

1000.01 and over 0.220

Use a function Tax_Rate() to determine the schedule. Pass the gross pay to Tax_Rate() and have the function return the rate.

Next, use the function Calc_Fed_Tax() to calculate the federal tax. The first argument should be the address of the gross income. The second argument should be the address of the tax rate (as returned by Tax_Rate()). The third argument should be the address of the number of dependents. The amount of the federal tax should be returned in the target of the fourth argument.

Finally, the program should calculate the net pay by subtracting the federal tax from the gross income. The program should display the person's name, social security number, gross pay, number of dependents, federal tax, and net pay.

Solution:

CODE (C++)
#include <iostream>
#include <string>
#include <iomanip>


using namespace std;


float Tax_Rate(float gross_pay) {
if ((0 <= gross_pay) && (gross_pay <= 300)) {
return 0.085;
}
if ((300.01 <= gross_pay) && (gross_pay <= 500)) {
return 0.120;
}
if ((500.01 <= gross_pay) && (gross_pay <= 1000)) {
return 0.120;
}
if (1000.01 <= gross_pay) {
return 0.220;
}
}
void Calc_Fed_Tax(float gross_pay, float tax_rate, float number_of_dependents,
float &federal_tax) {
federal_tax = gross_pay * tax_rate;
}


int main() {

string person_name;

string social_security_number;

float gross_pay;

float number_of_dependents;</iomanip></string></iostream>

// Input

cout << "Person name: ";

cin >> person_name;

cout << "Social security number: ";

cin >> social_security_number;

cout << "Gross pay: ";

cin >> gross_pay;

cout << "Number of dependents: ";

cin >> number_of_dependents;

float tax_rate = Tax_Rate(gross_pay);

float federal_tax;

Calc_Fed_Tax(gross_pay, tax_rate, number_of_dependents, federal_tax);

float net_pay = gross_pay - federal_tax;

cout << fixed << setprecision(2) << endl;

// Output

cout << "Person name: " << person_name << endl;

cout << "Social security number: " << social_security_number << endl;

cout << "Gross pay: " << gross_pay << endl;

cout << "Number of dependents: " << number_of_dependents << endl;

cout << "Federal tax: " << federal_tax << endl;

cout << "Net pay: " << net_pay << endl;

return 0;

}

OUTPUT

Person name: Andrew

Social security number: 123-123

Gross pay: 450

Number of dependents: 12

Person name: Andrew

Social security number: 123-123

Gross pay: 450.00

Number of dependents: 12.00

Federal tax: 54.00

Net pay: 396.00

Process returned 0 (0x0) execution time : 9.505 s

Press any key to continue.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS