Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a federal income tax calculator using C++ The United States federal perso

ID: 3881666 • Letter: C

Question

Create a federal income tax calculator using C++

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

Explanation / Answer

Hi.. I have written c++ program below. Please check it.

Main.cpp


#include <iostream>

using namespace std;

int main()
{
//cout<<"Hello World";
  
bool flag = true;
int input=0;
while(flag){
  
cout << "Enter filing status ";
cout << "(0-single filer, 1-head of household, 2-married jointly, 3-married separately):";
cin>>input;
cout << "Enter Taxable income:";
double income=0.0;
cin>>income;
double tax = 0.0;
switch(input){
  
case 0: if(income<=9225){
tax = 9225 x 0.1;
}else if(income>=9226 && income<=37450){
tax = 9225 x 0.1 + (income – 9225) x 0.15;
}else if(income>=37451 && income<=90750){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (income – 37450) x 0.25;
}else if(income>=90751 && income<=189300){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (90750 – 37450) x 0.25 + (income – 90750) x 0.28;
}else if(income>=189301 && income<=411500){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (90750 – 37450) x 0.25 + (189300 – 90750) x 0.28 + (income – 189300) x 0.33;
  
}else if(income>=411501 && income<=413200){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (90750 – 37450) x 0.25 + (189300 – 90750) x 0.28 + (411500 – 189300) x 0.33 + (income – 411500) x 0.35;
  
}else if(income>=413201){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (90750 – 37450) x 0.25 + (189300 – 90750) x 0.28 + (411500 – 189300) x 0.33 + (413200 – 411500) x 0.35 + (income – 413200) x 0.396;
  
}
cout << "Tax is " << tax << " ";
break;
case 1: if(income<=13150){
tax = 13150 x 0.1;
}else if(income>=13151 && income<=50200){
tax = 13150 x 0.1 + (income – 13150) x 0.15;
}else if(income>=50201 && income<=129600){
tax = 13150 x 0.1 + (50200 – 13150) x 0.15 + (income – 50200) x 0.25;
}else if(income>=129601 && income<=209850){
tax = 13150 x 0.1 + (50200 – 13150) x 0.15 + (129600 – 50200) x 0.25 + (income – 129600) x 0.28;
}else if(income>=209851 && income<=411500){
tax = 13150 x 0.1 + (50200 – 13150) x 0.15 + (129600 – 50200) x 0.25 + (209850 – 129600) x 0.28 + (income – 209850) x 0.33;
  
}else if(income>=411501 && income<=439000){
tax = 13150 x 0.1 + (50200 – 13150) x 0.15 + (129600 – 50200) x 0.25 + (209850 – 129600) x 0.28 + (411500 – 209850) x 0.33 + (income – 411500) x 0.35;
  
}else if(income>=439001){
tax = 13150 x 0.1 + (50200 – 13150) x 0.15 + (129600 – 50200) x 0.25 + (209850 – 129600) x 0.28 + (411500 – 209850) x 0.33 + (439000 – 411500) x 0.35 + (income – 439000) x 0.396;
  
}
cout << "Tax is " << tax << " ";
break;
case 2:
if(income<=18450){
tax = 18450 x 0.1;
}else if(income>=18451 && income<=74900){
tax = 18450 x 0.1 + (income – 18450) x 0.15;
}else if(income>=74901 && income<=151200){
tax = 18450 x 0.1 + (74900 – 18450) x 0.15 + (income – 74900) x 0.25;
}else if(income>=151201 && income<=230450){
tax = 18450 x 0.1 + (74900 – 18450) x 0.15 + (151200 – 74900) x 0.25 + (income – 151200) x 0.28;
}else if(income>=230451 && income<=411500){
tax = 18450 x 0.1 + (74900 – 18450) x 0.15 + (151200 – 74900) x 0.25 + (230450 – 151200) x 0.28 + (income – 230450) x 0.33;
  
}else if(income>=411501 && income<=464850){
tax = 18450 x 0.1 + (74900 – 18450) x 0.15 + (151200 – 74900) x 0.25 + (230450 – 151200) x 0.28 + (411500 – 230450) x 0.33 + (income – 411500) x 0.35;
  
}else if(income>=464851){
tax = 18450 x 0.1 + (74900 – 18450) x 0.15 + (151200 – 74900) x 0.25 + (230450 – 151200) x 0.28 + (411500 – 230450) x 0.33 + (464850 – 411500) x 0.35 + (income – 464850) x 0.396;
  
}
cout << "Tax is " << tax << " ";
break;
case 3: if(income<=9225){
tax = 9225 x 0.1;
}else if(income>=9226 && income<=37450){
tax = 9225 x 0.1 + (income – 9225) x 0.15;
}else if(income>=37451 && income<=75600){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (income – 37450) x 0.25;
}else if(income>=75601 && income<=115225){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (75600 – 37450) x 0.25 + (income – 75600) x 0.28;
}else if(income>=115226 && income<=205750){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (75600 – 37450) x 0.25 + (115225 – 75600) x 0.28 + (income – 115225) x 0.33;
  
}else if(income>=205751 && income<=232425){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (75600 – 37450) x 0.25 + (115225 – 75600) x 0.28 + (205750 – 115225) x 0.33 + (income – 205750) x 0.35;
  
}else if(income>=232426){
tax = 9225 x 0.1 + (37450 – 9225) x 0.15 + (75600 – 37450) x 0.25 + (115225 – 75600) x 0.28 + (205750 – 115225) x 0.33 + (232425 – 205750) x 0.35 + (income – 232425) x 0.396;
  
}
cout << "Tax is " << tax << " ";
break;
  
default: cout<<"Sorry Try agian";
break;
  
}
  
int choice = 0;
cout << "Do you like to continue? Type 1 to continue:";
cin >> choice;
  
  
if(choice!=1){
flag=false;
}
cout << " ";
  
}

return 0;
}

Output:

Enter filing status

(0-single filer, 1-head of household, 2-married jointly, 3-married separately):0

Enter Taxable income:4500

Tax is 7043.75

Do you like to continue? Type 1 to continue:0

Please check the code and let me know any issues. Thank you. All the best.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote