Pad 10:50 PM Documents Undo You are to write a C++ program to compute federal pe
ID: 3863857 • Letter: P
Question
Pad 10:50 PM Documents Undo You are to write a C++ program to compute federal personal income taxes. Program is to have no global variables. Use the concepts we have encountered in the first seven chapters. You are not to use functions, enums, arrays, structs, classes, or pointers. The tax owned depends on how much money one makes as well as their filing status. For use four filing statuses. These are ()single filers, (2)married filing our purposes we wi inintlv Rhmarried filino senaratelv and u4hhead nf hem erhald Tax Single Filers Married Filing Married Filing Head of Jointly Separately 2 12% Up to S7,550 Up to S15.100 Up to S7,550 Up to S10,750 3 16% S7.551-S30,650 S15,101-S61,300 S7,551-S30,650 S10,751-S41,050 4 20% S30,651-S74,200 S61,301-S123,700 S30,651-S61,850 S41,051-S106,000 28% S74, 201-S154,800 S123,701- $61,851-S94.225 S106,001- S171,650 S188,450 32% S154,801- S188,451- $94,226 S168,275 S171,651- S336,550 S336,550 S336,550 7 40% S336,551 or more S336,551 or more S168,276 or more S336,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 S450,000 for a single filer, S7,550 is taxed at 12%, ($30,650-S7,550) at 16%, (S74,200-S30,650) at 20% (S154,800- S74,200) at 28%, (S336,550-$154.800) at 32%, and (S450,000-336,550) at 40% for a tax amount of S139,419. Variables Name Type Description and edit specifications status Code int Status code must be from l to 4. l single, 2 married filing jointly, 3 married filing separately, 4 head of household, 9-end processing. taxable Income float Taxable income is entered by the user from the keyboard. The amount must be numeric and not less than S3000. tax Amt is a calculated field and is determined from the supplied tax table as applied to the taxablelncome. 75%Explanation / Answer
Here is the code for the question . Sample output is attached. Please do rate the answer if it helped. Thanks.
#include <iostream>
using namespace std;
/*
Program to compute tax for different filing status and tax rates for income range
*/
int main()
{
//variables to store input
int statusCode;
float taxableIncome;
float taxAmt=0; //variable to store the result
bool valid; //variable to indicate if user input is valid or not
float diff; //the difference in range to taxable amount
float income;
while(true)
{
do
{
valid=true; //assume input will be valid
//display the status code to user and get his valid status code
cout<<" The codes are : ";
cout<<" 1. Single";
cout<<" 2. Married filing jointly";
cout<<" 3. Married filing separately";
cout<<" 4. Head of household";
cout<<" 9. End processing ";
cout<<" Enter your status code : ";
cin>>statusCode;
if(statusCode==9) //check if we need to stop
{
return 0;
}
else if(statusCode<1 || statusCode>4)
{
cout<<" Please enter a valid status code.";
valid=false; //set to false since invalid input
}
}while(!valid);
//get a valid taxable income
do
{
valid=true; //assume input will be valid
cout<<" Enter your taxable income : ";
cin>>taxableIncome;
if( taxableIncome<3000) //check if income is valid or not
{
cout<<" Taxable income should not be less than $3000.";
valid=false; //set to false since invalid input
}
}while(!valid);
income=taxableIncome;
taxAmt=0;
//calculate the tax amount based on different statusCode values
switch(statusCode)
{
case 1:
printf(" Filing status : Single Filer ");
if(income>336550) // income 336551 and more
{
diff=income-336550;
taxAmt=0.4*diff;
income=income-diff;
}
if(income>154800) //for range 154801-336550
{
diff=income-154800;
taxAmt=taxAmt+0.32*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>74200) //for range 74201-154800
{
diff=income-74200;
taxAmt=taxAmt+0.28*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>30650) //for range 30651-74200
{
diff=income-30650;
taxAmt=taxAmt+0.2*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>7550) //for range 7551-30650
{
diff=income-7550;
taxAmt=taxAmt+0.16*diff; //add it to previous tax bracket value
income=income-diff;
}
//upto 7550
taxAmt=taxAmt+0.12*income;
break;
case 2:
printf(" Filing Status : Married Filing Jointly");
if(income>336550) // income 336551 and more
{
diff=income-336550;
taxAmt=0.4*diff;
income=income-diff;
}
if(income>188450) //for range 188451-336550
{
diff=income-188450;
taxAmt=taxAmt+0.32*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>123700) //for range 123701-188450
{
diff=income-123700;
taxAmt=taxAmt+0.28*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>61300) //for range 61301-123700
{
diff=income-61300;
taxAmt=taxAmt+0.2*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>15100) //for range 15101-61300
{
diff=income-15100;
taxAmt=taxAmt+0.16*diff; //add it to previous tax bracket value
income=income-diff;
}
//upto 15100
taxAmt=taxAmt+0.12*income;
break;
case 3:
printf(" Filing status : Married Filing Separately");
if(income>168275) // income 168276 and more
{
diff=income-168275;
taxAmt=0.4*diff;
income=income-diff;
}
if(income>94225) //for range 94226-168275
{
diff=income-94225;
taxAmt=taxAmt+0.32*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>61850) //for range 61851-94225
{
diff=income-61850;
taxAmt=taxAmt+0.28*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>30650) //for range 30651-61850
{
diff=income-30650;
taxAmt=taxAmt+0.2*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>7550) //for range 7551-30650
{
diff=income-7550;
taxAmt=taxAmt+0.16*diff; //add it to previous tax bracket value
income=income-diff;
}
//upto 7550
taxAmt=taxAmt+0.12*income;
break;
case 4:
printf(" Filing status : Head of Household");
if(income>336550) // income 336551 and more
{
diff=income-336550;
taxAmt=0.4*diff;
income=income-diff;
}
if(income>171650) //for range 171651-336550
{
diff=income-171650;
taxAmt=taxAmt+0.32*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>10600) //for range 10601-171650
{
diff=income-10600;
taxAmt=taxAmt+0.28*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>41050) //for range 41051-10600
{
diff=income-41050;
taxAmt=taxAmt+0.2*diff; //add it to previous tax bracket value
income=income-diff;
}
if(income>10750) //for range 10751-41050
{
diff=income-10750;
taxAmt=taxAmt+0.16*diff; //add it to previous tax bracket value
income=income-diff;
}
//upto 10750
taxAmt=taxAmt+0.12*income;
break;
default:
;//do nothing
}
printf(" Taxable Income : $%.2f",taxableIncome); //formatting to have 2 decimal places
printf(" Tax Amount : $%.2f",taxAmt);
printf(" ________________________________");
}
}
sample output
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 7
Please enter a valid status code.
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 1
Enter your taxable income : 1000
Taxable income should not be less than $3000.
Enter your taxable income : 10000
Filing status : Single Filer
Taxable Income : $10000.00
Tax Amount : $1298.00
________________________________
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 2
Enter your taxable income : 70000
Filing Status : Married Filing Jointly
Taxable Income : $70000.00
Tax Amount : $10944.00
________________________________
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 3
Enter your taxable income : 120000
Filing status : Married Filing Separately
Taxable Income : $120000.00
Tax Amount : $28155.00
________________________________
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 4
Enter your taxable income : 200000
Filing status : Head of Household
Taxable Income : $200000.00
Tax Amount : $55438.00
________________________________
The codes are :
1. Single
2. Married filing jointly
3. Married filing separately
4. Head of household
9. End processing
Enter your status code : 9
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.