Question
Given Code #include using namespace std; double compuTax(double income, int r1, int r2, int r3, int r4, int r5, int r6) { return 0; //
Given Code
#include
using namespace std;
double compuTax(double income, int r1, int r2, int r3, int r4, int r5, int r6) {
return 0; // replace return 0 with your code
}
int main()
{
int status, contNue;
double income;
do
{
//Prompt user to enter filing status and taxable income
cout << "Enter the filing status "
<< "(0-single filer, 1-head of household, "
<< "2-married jointly, 3-married separately): ";
cin >> status;
cout << "Enter the table income: ";
cin >> income;
//Call function compuTax to compute tax
double tax;
if (status == 0) tax = compuTax (income, 9225, 37450, 90750, 189300, 411500, 413200);
else if (status == 1) tax = compuTax (income, 13150, 50200, 129600, 209850,411500, 43900);
else if (status == 2) tax = compuTax (income, 18450, 74900, 151200, 230450, 411500, 464850);
else if (status == 3) tax = compuTax (income, 9225, 37450, 75600, 115225, 205750, 232425);
// Display results
cout << "Tax is " << static_cast
//Continue the tax computing?
cout << "Do you like to continue? Type 1 to continue: ";
cin >> contNue;
} while (contNue == 1);
return 0;
}
The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing status: single filers, married jointly, married filing separately, and head of household. The tax rates for 2015 are shown in the table below.
Tax Rate Single Filers Head of Household Married Filing Jointly Married Filing Separately 10% up to $9,225 up to $13,150 up to $18,450 up to $9,225 15% $9,226 - $37,450 $13,151 - $50,200 $18,451 - $74,900 $9226 - $37,450 25% $37,451 - $90,750 $50,201 129,600 $74,901 - $151,200 $37,451 75,600 28% $90,751 - $189,300 $129,601 - $209,850 $151,201 - $230,450 $75,601 - $115,225 33% $189,301 - $411,500 $209,851 - $411,500 $230,451 - $411,500 $115,226 - $205,750 35% $411,501 - $413,200 $411,501 - $439,000 $411,501 - $464 850 $205,751 - $232,425 39.6% $413,201 or more $439,001 or more $464,851 or more $232,426 or more
Example:
If you are single with taxable income of $45,000, the first $9,225 is taxed at 10%, the next $9,226 - $37,450 is taxed at 15%, and the last $37,451 - $40,000 is taxed at 25%. So, your tax is 9225 x 0.1 + (37450 9225) x 0.15 + (45000 37450) x 0.25 = 7043.75 US$.
Design a function to compute the tax for a given filing status and income. The function takes income, and tax bracket boundaries as parameters as inputs, and return the tax computed. The income and tax bracket boundaries must use double data type. Test code is included in the zyBook that produces output similar to the examples below.
Sample Inputs/Outputs Enter the filing status (0-single filer, 1-head of household, 2-married jointly, 3-married separately): 0 Enter the table income: 36000 Tax is 4938.75 Do you like to continue? Type 1 to continue: 1 Enter the filing status (0-single filer, 1-head of household, 2-married jointly, 3-married separately): 1 Enter the table income: 56000 Tax is 8322.5 Do you like to continue? Type 1 to continue: 1 Enter the filing status (0-single filer, 1-head of household, 2-married jointly, 3-married separately): 2 Enter the table income: 89000 Tax is 13837.5 Do you like to continue? Type 1 to continue: 1 Enter the filing status (0-single filer, 1-head of household, 2-married jointly, 3-married separately): 3 Enter the table income: 103890 Tax is 22615 Do you like to continue? Type 1 to continue: 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started