In: Computer Science
Write a program that can calculate the amount of federal tax a person owes for the upcoming year.
After calculating the amount of tax owed, you should report to the user their filing status (single/joint), which tax rate they fell under, as well as the tax owed. Example: “As a single filer you fell under 12% tax bracket and you owe $3500.”
Disclaimer: This example is simplified and is not intended to be an accurate representation of how to calculate your taxes.
Your program should ask the user if they are a single filer, or if they will be filing jointly with their spouse. If they file single, ask the user to input their total income for the year. If they file jointly then have the user enter both their income as well as their spouse’s income. (You can then add the 2 incomes together to obtain gross household income.)
Your program should also check to see if the person is eligible for the Earned Income Credit (EIC). EIC eligibility is dependent upon both filing status as well as number of dependents. Therefore, ask the user to enter how many children (dependents) they have.
Assume that if the person is eligible then the EIC deducts 8% from the gross income, so that only 92% of the gross income is now taxable. (The EIC will reduce the amount of income which is taxable, but does not change the person’s tax bracket.
Ex: If the person made $40,000 (single) then they are in the 22% bracket. The EIC makes their taxable income 40,000*0.92 = $36,800. This new total is within the 12% bracket, but the person still owes 22% of the $36,800.
Table 1 Earned Income Credit Limits
Filing Status | Income Limit if No Children | Income Limit if 1 Child | Income Limit if 2 Children | Income Limit if 3+ Children |
Married Joint |
Table 2 Tax Brackets for SINGLE filers
Tax Rate | Taxable Income Bracket | Tax Owed |
$0 to $9,525 | 10% of taxable income | |
$9,526 to $38,700 | $952.50 plus 12% of the amount over $9,525 | |
$38,701 to $82,500 | $4,453.50 plus 22% of the amount over $38,700 | |
$82,501 to $157,500 | $14,089.50 plus 24% of the amount over $82,500 | |
$157,501 to $200,000 | $32,089.50 plus 32% of the amount over $157,500 | |
$200,001 to $500,000 | $45,689.50 plus 35% of the amount over $200,000 | |
$500,001 or more | $150,689.50 plus 37% of the amount over $500,000 |
Table 3 Tax Brackets for JOINT filers
Tax Rate | Taxable Income Bracket | Tax Owed |
$0 to $19,050 | 10% of taxable income | |
$19,051 to $77,400 | $1,905 plus 12% of the amount over $19,050 | |
$77,401 to $165,000 | $8,907 plus 22% of the amount over $77,400 | |
$165,001 to $315,000 | $28,179 plus 24% of the amount over $165,000 | |
$315,001 to $400,000 | $64,179 plus 32% of the amount over $315,000 | |
$400,001 to $600,000 | $161,379 plus 35% of the amount over $400,000 | |
$600,001 or more | $161,379 plus 37% of the amount over $600,000 |
ScreenShot
Program
//Header File for input/output
#include
using namespace std;
//Function prototypes
void jointTaxCalculation();
void singleTaxCalculation();
int main()
{
//Variable for check single or joint filing
char ch;
//Prompt user for type of filing
cout << "Are you (S)ingle/(J)oint filer?";
cin >> ch;
//If the user choice wrong check
while (ch != 'S' && ch != 's' && ch !=
'J' && ch != 'j') {
cout << "Are you
(S)ingle/(J)oint filer?";
cin >> ch;
}
//If joint call fuction for tax calculation
if (ch == 'j' || ch == 'J') {
jointTaxCalculation();
}
//If singlecall fuction for tax calculation
else {
singleTaxCalculation();
}
return 0;
}
//Joint calculation
void jointTaxCalculation() {
//Variable for user input
int dep;
double income1,
income2,totalIncome,percentage,tax;
//Prompt user to enter income amount
cout << "Please enter both incomes:";
cin >> income1 >> income2;
//Calculate total income
totalIncome = income1 + income2;
//Prompt for dependencies
cout << "How many dependence(Children) you
have?";
cin >> dep;
//According to dependency calculate EIC
if (dep == 0) {
percentage = 1;
}
else if (dep == 1) {
percentage = .92;
}
else if (dep == 2) {
percentage = .84;
}
else if (dep >= 3) {
percentage = .76;
}
//findout tax limits and accordingly calculate
tax
if (totalIncome >= 0 && totalIncome <=
19050) {
tax =( (totalIncome *
percentage)*(10 / 100));
cout << "As a Joint filer you
fell under 10% tax bracket and you owe $" << tax <<
"."<
else if (totalIncome >= 19051 &&
totalIncome <= 77400) {
tax = (1905+(((totalIncome*
percentage)- 19051 )*(12 / 100)));
cout << "As a Joint filer you
fell under 12% tax bracket and you owe $" << tax << "."
<< endl;
}
else if (totalIncome >= 77401 &&
totalIncome <= 165000) {
tax = (8907 + (((totalIncome*
percentage) - 77400)*(22 / 100)));
cout << "As a Joint filer you
fell under 22% tax bracket and you owe $" << tax << "."
<< endl;
}
else if (totalIncome >= 165001 &&
totalIncome <= 315000) {
tax = (28179 + (((totalIncome*
percentage) - 165000)*(24/ 100)));
cout << "As a Joint filer you
fell under 24% tax bracket and you owe $" << tax << "."
<< endl;
}
else if (totalIncome >= 315001 &&
totalIncome <=400000) {
tax = (64179 + (((totalIncome*
percentage) - 315000)*(32 / 100)));
cout << "As a Joint filer you
fell under 32% tax bracket and you owe $" << tax << "."
<< endl;
}
else if (totalIncome >= 400001 &&
totalIncome <= 600000) {
tax = (161379 + (((totalIncome*
percentage) - 400000)*(35 / 100)));
cout << "As a Joint filer you
fell under 35% tax bracket and you owe $" << tax << "."
<< endl;
}
else if (totalIncome >= 600001) {
tax = (161379 + (((totalIncome*
percentage) - 600000)*(37 / 100)));
cout << "As a Joint filer you
fell under 37% tax bracket and you owe $" << tax << "."
<< endl;
}
}
//Single calculation
void singleTaxCalculation() {
//Variable for user input
int dep;
double income1,totalIncome, percentage, tax;
//Prompt user to enter income amount
cout << "Please enter your income:";
cin >> income1;
//Calculate total income
totalIncome = income1;
//Prompt for dependencies
cout << "How many dependence(Children) you
have?";
cin >> dep;
//According to dependency calculate EIC
if (dep == 0) {
percentage = 1;
}
else if (dep == 1) {
percentage = .92;
}
else if (dep == 2) {
percentage = .84;
}
else if (dep >= 3) {
percentage = .76;
}
//findout tax limits and accordingly calculate
tax
if (totalIncome >= 0 && totalIncome
<=9525) {
tax = ((totalIncome *
percentage)*(10 / 100));
cout << "As a Single filer
you fell under 10% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 9526 && totalIncome
<= 38700) {
tax = (952.50 + (((totalIncome*
percentage) - 9525)*(12 / 100)));
cout << "As a Single filer
you fell under 12% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 38701 &&
totalIncome <= 82500) {
tax = (4453.50 + (((totalIncome*
percentage) - 38700)*(22 / 100)));
cout << "As a Single filer
you fell under 22% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 82501 &&
totalIncome <= 157500) {
tax = (14089.50 + (((totalIncome*
percentage) - 82500)*(24 / 100)));
cout << "As a Single filer
you fell under 24% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 157501 &&
totalIncome <= 200000) {
tax = (32089.50 + (((totalIncome*
percentage) - 157500)*(32 / 100)));
cout << "As a Single filer
you fell under 32% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 200001 &&
totalIncome <= 500000) {
tax = (45689.50 + (((totalIncome*
percentage) - 200000)*(35 / 100)));
cout << "As a Single filer
you fell under 35% tax bracket and you owe $" << tax <<
"." << endl;
}
else if (totalIncome >= 500001) {
tax = (150689.50 + (((totalIncome*
percentage) - 500000)*(37 / 100)));
cout << "As a Single filer
you fell under 37% tax bracket and you owe $" << tax <<
"." << endl;
}
}
--------------------------------------------------------------------------
Output
Are you (S)ingle/(J)oint filer?s
Please enter your income:40000
How many dependence(Children) you have?1
As a Single filer you fell under 22% tax bracket and you owe
$4453.5.