iPod 10:09 PM gotoclass.tnecampus.org You are to modify the midterm examination
ID: 3828008 • Letter: I
Question
iPod 10:09 PM gotoclass.tnecampus.org You are to modify the midterm examination to take advantages of many of the features that we have encountered in chapters 8 through 12. The primary objective of the solution remains to compute federal personal income taxes. The solution can have NO global variables. The tax liability depends on how much money one makes as well as their filing status. For our purposes we will use four filing statuses. These are (1)single filers, (2)married filing jointly, (3)married filing separately, and (4)head of household. For each filing status there are six tax rates. Each rate is applied to a given amount of the taxable income. For example, for a taxable income ofS450,000 for a single filer, $7,550 is taxed at 12%, (S30,650-S7,550) at 16%, (S74.200-$30,650) at 20%. (S154.800-S74.200) at 28%. (S336,550 S154,800) at 32%, and (S450,000-336,550) at The six tax rates are to be stored in a one-dimensional array with data type float. The four filing status descriptions are to be stored in a one-dimensional array of data type string. Variables Name MaDescri ion and edit Status code must be from Ilo4 "single, 2-mamied filing jointly, 3 married filing separately, 4 head of axable income is entered by the user fremthe keyboard The amount mu be and not less than S3000. calculated field and is determined the Your program should be modular and contain at least4 user defined functions beyond the mai function. You are to follow these specifications as closely as possible. You should have functions that do the following:Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int statusCode;
double taxableIncome, taxAmt;
while(true)
{
do
{
cout <<"Enter the status code 1. Single. 2. Married filing jointly. 3. Married filing separately. 4. Head of household. 9. End processing. ";
cout << "Enter your choice: ";
cin >> statusCode;
}while(statusCode != 1 && statusCode != 2 && statusCode != 3 && statusCode != 4 && statusCode != 9);
if(statusCode == 9)
return 0;
do
{
cout <<"Enter your taxable income (>= $3000): ";
cin >> taxableIncome;
}while(taxableIncome < 3000);
switch(statusCode)
{
case 1:
if(taxableIncome >= 0 && taxableIncome <= 7550)
taxAmt = 0.12 * taxableIncome;
else if(taxableIncome > 7550 && taxableIncome <= 30650)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04;
else if(taxableIncome > 30650 && taxableIncome <= 74200)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04;
else if(taxableIncome > 74200 && taxableIncome <= 154800)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 74200) * 0.08;
else if(taxableIncome > 154800 && taxableIncome <= 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 74200) * 0.08 + (taxableIncome - 154800) * 0.04;
else if(taxableIncome > 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 74200) * 0.08 + (taxableIncome - 154800) * 0.04 + (taxableIncome - 336550) * 0.08;
cout << "Filing status: Single" << endl;
break;
case 2:
if(taxableIncome >= 0 && taxableIncome <= 15100)
taxAmt = 0.12 * taxableIncome;
else if(taxableIncome > 15100 && taxableIncome <= 61300)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 15100) * 0.04;
else if(taxableIncome > 61300 && taxableIncome <= 123700)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 15100) * 0.04 + (taxableIncome - 61300) * 0.04;
else if(taxableIncome > 123700 && taxableIncome <= 188450)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 15100) * 0.04 + (taxableIncome - 61300) * 0.04 + (taxableIncome - 123700) * 0.08;
else if(taxableIncome > 188450 && taxableIncome <= 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 15100) * 0.04 + (taxableIncome - 61300) * 0.04 + (taxableIncome - 123700) * 0.08 + (taxableIncome - 188450) * 0.04;
else if(taxableIncome > 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 15100) * 0.04 + (taxableIncome - 61300) * 0.04 + (taxableIncome - 123700) * 0.08 + (taxableIncome - 188450) * 0.04 + (taxableIncome - 336550) * 0.08;
cout << "Filing status: Married Filing Jointly" << endl;
break;
case 3:
if(taxableIncome >= 0 && taxableIncome <= 7550)
taxAmt = 0.12 * taxableIncome;
else if(taxableIncome > 7550 && taxableIncome <= 30650)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04;
else if(taxableIncome > 30650 && taxableIncome <= 61850)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04;
else if(taxableIncome > 61850 && taxableIncome <= 94225)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 61850) * 0.08;
else if(taxableIncome > 94225 && taxableIncome <= 168275)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 61850) * 0.08 + (taxableIncome - 94225) * 0.04;
else if(taxableIncome > 168275)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 7550) * 0.04 + (taxableIncome - 30650) * 0.04 + (taxableIncome - 61850) * 0.08 + (taxableIncome - 94225) * 0.04 + (taxableIncome - 168275) * 0.08;
cout << "Filing status: Married Filing Separately" << endl;
break;
case 4:
if(taxableIncome >= 0 && taxableIncome <= 10750)
taxAmt = 0.12 * taxableIncome;
else if(taxableIncome > 10750 && taxableIncome <= 41050)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 10750) * 0.04;
else if(taxableIncome > 41050 && taxableIncome <= 106000)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 10750) * 0.04 + (taxableIncome - 41050) * 0.04;
else if(taxableIncome > 106000 && taxableIncome <= 171650)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 10750) * 0.04 + (taxableIncome - 41050) * 0.04 + (taxableIncome - 106000) * 0.08;
else if(taxableIncome > 171650 && taxableIncome <= 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 10750) * 0.04 + (taxableIncome - 41050) * 0.04 + (taxableIncome - 106000) * 0.08 + (taxableIncome - 171650) * 0.04;
else if(taxableIncome > 336550)
taxAmt = taxableIncome * 0.12 + (taxableIncome - 10750) * 0.04 + (taxableIncome - 41050) * 0.04 + (taxableIncome - 106000) * 0.08 + (taxableIncome - 171650) * 0.04 + (taxableIncome - 336550) * 0.08;
cout << "Filing status: Head of Household" << endl;
break;
case 9: return 0;
}
cout << "Taxable income: $" << fixed << setprecision(2) << taxableIncome << endl;
cout << "Tax amount: $" << fixed << setprecision(2) << taxAmt << endl;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.