You are to write a C++ program to compute federal personal income taxes. Program
ID: 3918396 • Letter: Y
Question
You are to write a C++ program to compute federal personal income taxes. Program is to have noglobal variables. Use the concepts we have encountered in the first seven chapters. You are not to usefunctions, enums, arrays, structs, classes, or pointers.
The tax owned 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.
Tax Rate
Single Filers
Married Filing Jointly
Married Filing Separately
Head of Household
12%
Up to $7,550
Up to $15,100
Up to $7,550
Up to $10,750
16%
$7,551-$30,650
$15,101-$61,300
$7,551-$30,650
$10,751-$41,050
20%
$30,651-$74,200
$61,301-$123,700
$30,651-$61,850
$41,051-$106,000
28%
$74,201-$154,800
$123,701-$188,450
$61,851-$94,225
$106,001-$171,650
32%
$154,801-$336,550
$188,451-$336,550
$94,226-$168,275
$171,651-$336,550
40%
$336,551 or more
$336,551 or more
$168,276 or more
$336,551 or more
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 of $450,000 for a single filer, $7,550 is taxed at 12%, ($30,650-$7,550) at 16%, ($74,200-$30,650) at 20%, ($154,800-$74,200) at 28%, ($336,550-$154,800) at 32%, and ($450,000-336,550) at 40% for a tax amount of $139,419.
Variables
Name
Type
Description and edit specifications
statusCode
int
Status code must be from 1 to 4. 1=single, 2=married filing jointly, 3=married filing separately, 4= head of household, 9 = end processing.
taxableIncome
float
Taxable income is entered by the user from the keyboard. The amount must be numeric and not less than $3000.
taxAmt
float
taxAmt is a calculated field and is determined from the supplied tax table as applied to the taxableIncome.
Your program should be modular, that is small blocks of code. (Later in the semester when we encounter functions, you will see how handy modular development can be.) You are to follow these specifications as closely as possible. You should have code blocks that do the following:
Input status code. You should use a do/while loop to control the input logic. You are to keep the user in the loop until the input is correct. You are to ensure that the status codes are as specified above.
Input taxable income. As in step 1, you are to use a do/while loop for this logic. You are to keep the user in the loop until the input is valid.
Calculate the tax owned as a result of status code and taxable income. You are to use a switch statement for the appropriate logic for each status code. You should manually calculate several cases to ensure your program is performing correctly.
Display the results of the calculation step. You are to output the status code, the string description of the status code, the taxable income, and the total tax amount. You are to use appropriate formatting of the output.
You main loop should be a while loop that repeat steps 1 through 4 until the user enters a status code of 9 that will terminate the job.
Hint: As you can see the tax rates are the same for each of the filing statuses. The primary differences in all the status groups are the range amounts for the applicable tax rates.
Example of calculations and resulting output (note: it is ok to take some liberties with the output format.)
Taxable Income: $70000, Filing status of Married Filing Jointly
Taxable income brackets
Tax rate
Tax amt.
15100
.12
1812.00
(61300 – 15100)
.16
7392.00
(70000 – 61300)
.20
1739.80
Total Taxes
10943.64
Display of above
Filing status: Married Filing Jointly
Taxable income: $70000.00
Tax amount: $10943.64
Tax Rate
Single Filers
Married Filing Jointly
Married Filing Separately
Head of Household
12%
Up to $7,550
Up to $15,100
Up to $7,550
Up to $10,750
16%
$7,551-$30,650
$15,101-$61,300
$7,551-$30,650
$10,751-$41,050
20%
$30,651-$74,200
$61,301-$123,700
$30,651-$61,850
$41,051-$106,000
28%
$74,201-$154,800
$123,701-$188,450
$61,851-$94,225
$106,001-$171,650
32%
$154,801-$336,550
$188,451-$336,550
$94,226-$168,275
$171,651-$336,550
40%
$336,551 or more
$336,551 or more
$168,276 or more
$336,551 or more
Explanation / Answer
ScreenShot
---------------------------------------------------------------------
Program
//Header file for I/o and cin fail check
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
//Variable for status of tax payer,Taxable income and tax calculation
int statusCode;
float taxbleIncome;
float taxAmt;
//Loop to check the correct status enter
do {
cout << "Enter your status(1 for 1=single, 2=married filing jointly, 3=married filing separately, 4= head of household, 9 = end processing) : ";
cin >> statusCode;
} while (statusCode != 1 && statusCode != 2 && statusCode != 3 && statusCode != 4 && statusCode != 9);
//Continue loop until 9 enter
while (statusCode != 9) {
//Loop for income correct read
do {
cout << "Enter taxable income(>=$3000): ";
cin >> taxbleIncome;
} while (taxbleIncome < 3000 || cin.fail());
//Calculate tax according to the staus
switch (statusCode) {
//Tax Calculation of single filer
case 1:
cout << "Taxable Income: $" << taxbleIncome << ", Filing status of Single Filer" << endl;
cout << "------------------------------------------------------- ";
cout << "Taxable income brackets Tax rate Tax mount ---------------------------------------------------------" << endl;
if (taxbleIncome <= 7550) {
taxAmt = taxbleIncome * .12;
cout << "7550 .12 $" << taxAmt << endl;
cout << "-------------------------------------------------------- Total Taxes $"<<taxAmt<<endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 7551 && taxbleIncome <= 30650) {
taxAmt = 7550 * .12+ (taxbleIncome - 7550)*.16;;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << taxbleIncome<<"-7550 .16 $" << (taxbleIncome - 7550)*.16 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 30651 && taxbleIncome <= 74200) {
taxAmt = 7550 * .12+(30650-7550) *.16 +(taxbleIncome -30650)*.20;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << taxbleIncome << "-30650 .20 $" << (taxbleIncome - 30650)*.20 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 74201 && taxbleIncome <= 154800) {
taxAmt = 7550 * .12 + (30650-7550) * .16 + (74200-30650) * .20 + (taxbleIncome -74200)*.28;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "74200-30650 .20 $" << (74200 - 30650)*.20 << endl;
cout << taxbleIncome << "-74200 .28 $" << (taxbleIncome - 74200)*.28 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 154801 && taxbleIncome <= 336550) {
taxAmt = 7550 * .12 + (30650 - 7550) * .16 + (74200 - 30650) * .20 + (154800 - 74200) * .28 + (taxbleIncome - 154800)*.32;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "74200-30650 .20 $" << (74200 - 30650)*.20 << endl;
cout << "154800 - 74200 .28 $" << (154800 - 74200)*.28 << endl;
cout << taxbleIncome << "-154800 .32 $" << (taxbleIncome - 154800)*.32 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 336551) {
taxAmt = 7550 * .12 + (30650-7550) * .16 +( 74200-30650) * .20 + (154800-74200) * .28 +(336550-154800) * .32 + (taxbleIncome -336550)*.40;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "74200-30650 .20 $" << (74200 - 30650)*.20 << endl;
cout << "154800 - 74200 .28 $" << (154800 - 74200)*.28 << endl;
cout << "336550-154800 .32 $" << (336550 - 154800)*.32 << endl;
cout << taxbleIncome << "-336550 .40 $" << (taxbleIncome - 336550)*.40 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
cout << "Filing status : Single Filer Taxable income : $" << taxbleIncome << " Tax amount : $" << taxAmt << endl;
break;
//Tax Calculation of Married joint filer
case 2:
cout << "Taxable Income: $" << taxbleIncome << ", Filing status of Married Filing Jointly" << endl;
cout << "------------------------------------------------------- ";
cout << "Taxable income brackets Tax rate Tax mount ---------------------------------------------------------" << endl;
if (taxbleIncome <= 15100) {
taxAmt = taxbleIncome * .12;
cout << "15100 .12 $" << taxAmt << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 15101 && taxbleIncome <= 61300) {
taxAmt = 15100 * .12 + (taxbleIncome - 15100)*.16;;
cout << "15100 .12 $" << 15100* .12 << endl;
cout << taxbleIncome << "-15100 .16 $" << (taxbleIncome - 15100)*.16 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 61301 && taxbleIncome <= 123700) {
taxAmt = 15100 * .12 + (61300 - 15100) *.16 + (taxbleIncome - 61300)*.20;
cout << "15100 .12 $" << 15100 * .12 << endl;
cout << "61300 - 15100 .16 $" << (61300 - 15100)*.16 << endl;
cout << taxbleIncome << "-61300 .20 $" << (taxbleIncome - 61300)*.20 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 123701 && taxbleIncome <= 188450) {
taxAmt = 15100 * .12 + (61300 - 15100) * .16 + (123700-61300) * .20 + (taxbleIncome - 123700)*.28;
cout << "15100 .12 $" << 15100 * .12 << endl;
cout << "61300 - 15100 .16 $" << (61300 - 15100)*.16 << endl;
cout << "123700-61300 .20 $" << (123700 - 61300)*.20 << endl;
cout << taxbleIncome << "-123700 .28 $" << (taxbleIncome - 123700)*.28 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 188450 && taxbleIncome <= 336550) {
taxAmt = 15100 * .12 + (61300 - 15100) * .16 + (123700 - 61300) * .20 + (188450-123700) * .28 + (taxbleIncome - 188450)*.32;
cout << "15100 .12 $" << 15100 * .12 << endl;
cout << "61300 - 15100 .16 $" << (61300 - 15100)*.16 << endl;
cout << "123700 - 61300 .20 $" << (123700 - 61300)*.20 << endl;
cout << "188450-123700 .28 $" << (188450 - 123700)*.28 << endl;
cout << taxbleIncome << "-188450 .32 $" << (taxbleIncome - 188450)*.32 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >=336551) {
taxAmt = 15100 * .12 + (61300 - 15100) * .16 + (123700 - 61300) * .20 + (188450 - 123700) * .28 + (336550 - 188450)*.32 + (taxbleIncome - 336550)*.40;
cout << "15100 .12 $" << 15100 * .12 << endl;
cout << "61300 - 15100 .16 $" << (61300 - 15100)*.16 << endl;
cout << "123700 - 61300 .20 $" << (123700 - 61300)*.20 << endl;
cout << "188450 - 123700 .28 $" << (188450 - 123700)*.28 << endl;
cout << "336550 - 188450 .32 $" << (336550 - 188450)*.32 << endl;
cout << taxbleIncome << "-336550 .40 $" << (taxbleIncome - 336550)*.40 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
cout << "Filing status : Married Filing Jointly Taxable income : $" << taxbleIncome << " Tax amount : $" << taxAmt << endl;
break;
//Tax Calculation of Married seperate filer
case 3:
cout << "Taxable Income: $" << taxbleIncome << ", Filing status of Married Filing Separately" << endl;
cout << "------------------------------------------------------- ";
cout << "Taxable income brackets Tax rate Tax mount ---------------------------------------------------------" << endl;
if (taxbleIncome <= 7550) {
taxAmt = taxbleIncome * .12;
cout << "7550 .12 $" << taxAmt << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 7551 && taxbleIncome <= 30650) {
taxAmt = 7550 * .12 + (taxbleIncome - 7550)*.16;;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << taxbleIncome << "-7550 .16 $" << (taxbleIncome - 7550)*.16 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 30651 && taxbleIncome <= 61850) {
taxAmt = 7550 * .12 + (30650 - 7550) *.16 + (taxbleIncome - 30650)*.20;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << taxbleIncome << "-30650 .20 $" << (taxbleIncome - 30650)*.20 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 61851 && taxbleIncome <= 94225) {
taxAmt = 7550 * .12 + (30650 - 7550) * .16 + (61850 - 30650) * .20 + (taxbleIncome - 61850)*.28;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "61850-30650 .20 $" << (61850 - 30650)*.20 << endl;
cout << taxbleIncome << "-61850 .28 $" << (taxbleIncome - 61850)*.28 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 94226 && taxbleIncome <= 168275) {
taxAmt = 7550 * .12 + (30650 - 7550) * .16 + (61850 - 30650) * .20 + (94225 - 61850) * .28 + (taxbleIncome - 94225)*.32;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "61850-30650 .20 $" << (61850 - 30650)*.20 << endl;
cout << "94225 - 61850 .28 $" << (94225 - 61850)*.28 << endl;
cout << taxbleIncome << "-94225 .32 $" << (taxbleIncome - 94225)*.32 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 168276) {
taxAmt = 7550 * .12 + (30650 - 7550) * .16 + (61850 - 30650) * .20 + (94225 - 61850) * .28 + (168275 - 94225) * .32 + (taxbleIncome - 168275)*.40;
cout << "7550 .12 $" << 7550 * .12 << endl;
cout << "30650-7550 .16 $" << (30650 - 7550)*.16 << endl;
cout << "61850-30650 .20 $" << (61850 - 30650)*.20 << endl;
cout << "94225 - 61850 .28 $" << (94225 - 61850)*.28 << endl;
cout << "168275-94225 .32 $" << (168275 - 94225)*.32 << endl;
cout << taxbleIncome << "-168275 .40 $" << (taxbleIncome - 167275)*.40 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
cout << "Filing status : Married Filing Separately Taxable income : $" << taxbleIncome << " Tax amount : $" << taxAmt << endl;
break;
//Tax calculation of head filer
case 4:
cout << "Taxable Income: $" << taxbleIncome << ", Filing status of Head of Household" << endl;
cout << "------------------------------------------------------- ";
cout << "Taxable income brackets Tax rate Tax mount ---------------------------------------------------------" << endl;
if (taxbleIncome <= 10750) {
taxAmt = taxbleIncome * .12;
cout << "10750 .12 $" << taxAmt << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 10751 && taxbleIncome <= 41050) {
taxAmt = 10750 * .12 + (taxbleIncome - 10750)*.16;;
cout << "10750 .12 $" << 10750 * .12 << endl;
cout << taxbleIncome << "-10750 .16 $" << (taxbleIncome - 10750)*.16 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 41051 && taxbleIncome <= 106000) {
taxAmt = 10750 * .12 + (41050 - 10750) *.16 + (taxbleIncome - 41050)*.20;
cout << "10750 .12 $" << 10750 * .12 << endl;
cout << "41050 - 10750 .16 $" << (41050 - 10750)*.16 << endl;
cout << taxbleIncome << "-41050 .20 $" << (taxbleIncome - 41050)*.20 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 106001 && taxbleIncome <= 171650) {
taxAmt = 10750 * .12 + (41050 - 10750) * .16 + (106000 - 41050) * .20 + (taxbleIncome - 106000)*.28;
cout << "10750 .12 $" << 10750 * .12 << endl;
cout << "41050 - 10750 .16 $" << (41050 - 10750)*.16 << endl;
cout << "106000-41050 .20 $" << (106000 - 41050)*.20 << endl;
cout << taxbleIncome << "-106000 .28 $" << (taxbleIncome - 106000)*.28 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 171651 && taxbleIncome <= 336550) {
taxAmt = 10750 * .12 + (41050 - 10750) * .16 + (74200 - 30650) * .20 + (154800 - 74200) * .28 + (taxbleIncome - 154800)*.32;
cout << "10750 .12 $" << 10750 * .12 << endl;
cout << "41050 - 10750 .16 $" << (41050 - 10750)*.16 << endl;
cout << "106000 - 41050 .20 $" << (106000 - 41050)*.20 << endl;
cout << "171650 - 106000 .28 $" << (171650 - 106000)*.28 << endl;
cout << taxbleIncome << "-171650 .32 $" << (taxbleIncome - 171650)*.32 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
else if (taxbleIncome >= 336551) {
taxAmt = 10750 * .12 + (41050 - 10750) * .16 + (106000 - 41050) * .20 + (171650 - 106000) * .28 + (336550 - 171650) * .32 + (taxbleIncome - 336550)*.40;
cout << "10750 .12 $" << 10750 * .12 << endl;
cout << "41050 - 10750 .16 $" << (41050 - 10750)*.16 << endl;
cout << "106000 - 41050 .20 $" << (106000 - 41050)*.20 << endl;
cout << "171650 - 106000 .28 $" << (171650 - 106000)*.28 << endl;
cout << "336550-171650 .32 $" << (336550 - 171650)*.32 << endl;
cout << taxbleIncome << "-336550 .40 $" << (taxbleIncome - 336550)*.40 << endl;
cout << "-------------------------------------------------------- Total Taxes $" << taxAmt << endl;
cout << "-------------------------------------------------------- ";
}
cout << "Filing status : Head of Household Taxable income : $" << taxbleIncome << " Tax amount : $" << taxAmt << endl;
break;
}
do {
cout << "Enter your status(1 for 1=single, 2=married filing jointly, 3=married filing separately, 4= head of household, 9 = end processing) : ";
cin >> statusCode;
} while (statusCode != 1 && statusCode != 2 && statusCode != 3 && statusCode != 4 && statusCode != 9);
}
//If 9 enter exit from while loop and exit from program
cout << "End the processing!!!" << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.