Program 4: In 1789, Benjamin Franklin is known to have written “Our new Constitution is now established, and has an appearance that promises permanency; but in this world nothing can be said to be certain, except death and taxes.” Our federal tax system is a “graduated” tax system which is broken into seven segments. Essentially, the more you make, the higher your tax rate. For 2018, you can find the tax brackets here. Your task is to design (pseudocode) and implement (C++ source code) a program that asks the user for a salary and calculates the federal tax owed. Note, that only the money above a particular tax bracket gets taxed at the higher rate. For example, if someone makes $10,000 a year, the first $9525 gets taxed at 10%. The “excess” above that ($475) gets taxed at 12%.
Sample run 1:
Enter your salary to the nearest dollar: 2000
Total tax owed is: $200
Sample run 2:
Enter your salary to the nearest dollar: 40000
Total tax owed is: $4739
Sample run 3:
Enter your salary to the nearest dollar: 100000
Total tax owed is: $18289
link for tax brackets:
https://www.hrblock.com/tax-center/irs/tax-brackets-and-rates/what-are-the-tax-brackets/
#include <iostream>
using namespace std;
/*10% Up to $9,525
12% $9,526 to $38,700
22% $38,701 to $82,500
24% $82,501 to $157,500
32% $157,501 to $200,000
35% $200,001 to $500,000
37% over $500,000
*/
int main()
{
int salary;
double tax=0;
cout<<"Enter your salary to the nearest dollar: ";
cin>>salary;
if(salary<=9525){
tax=952;
}
//checking for 2nd slot tax
if(salary >9525 && salary<=38700){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
}
//checking for 3rd slot tax
if(salary >38700 && salary<=82500){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
tax=(tax+(salary-38700)*0.22);
cout<<tax<<endl;
}
//checking for 4th slot tax
if(salary >82500 && salary<=157500){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
tax=(tax+(salary-38700)*0.22);
tax=(tax+(salary-82500)*0.24);
}
if(salary >157500 &&salary<=200000){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
tax=(tax+(salary-38700)*0.22);
tax=(tax+(salary-82500)*0.24);
tax=(tax+(salary-157500)*0.32);
}
if(salary >200000 &&salary<=500000){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
tax=(tax+(salary-38700)*0.22);
tax=(tax+(salary-82500)*0.24);
tax=(tax+(salary-157500)*0.32);
tax=(tax+(salary-200000)*0.35);
}
if(salary>500000){
tax=9525*0.1;
tax=(tax+(salary-9525)*0.12);
tax=(tax+(salary-38700)*0.22);
tax=(tax+(salary-82500)*0.24);
tax=(tax+(salary-157500)*0.32);
tax=(tax+(salary-200000)*0.35);
tax=(tax+(salary-500000)*0.37);
}
cout<<"Total tax owed is: $"<<tax;
return 0;
}
I have used the above tax rates . Please share the correct tax rates so that you will get the correct output
Get Answers For Free
Most questions answered within 1 hours.