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

1. The United States Federal personal income tax is calculated based on filing s

ID: 3537620 • Letter: 1

Question

1.      The United States Federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers (0) , married filing jointly or qualified widow(er) (1), married filing separately (2), and head of household(3). The tax rates vary every year. The table shows the rates for 2009.

Calculation for single with a taxable income of $10,000

In this case, the first $8350 is taxed at 10%, and the other $1650 ($10,000- $8350) is taxed at 15%.

tax = $8350 * 0.10 + (10000 - 8350) * 0.15 = $835 + $247.50 = $1082.50

Table - US Federal Personal Tax Rates for 2009

Marginal Tax Rate

Single

Married Filing Jointly or Qualifying Widow(er)

Married Filing separately

Head of Household

10%

$0 -$8,350

$0 - $16,700

$0 -$8,350

$0 - $11,950

15%

$8,351 - $33,950

$16,701 - $67,900

$8,351 - $33,950

$11,951 - $45,500

The status are given these numbers

0 - single filers

1 - married filing jointly or qualified widow(er)

2 - married filing separately

3 - head of household.

Write a C++ program for computing the tax using main and the computeTax function with the following header:

double computeTax(int status, double taxableIncome)

This is a value returning function that takes in the status, an integer and taxable income, a double and returns a double.


Use this function to write a program that prints a tax table for taxable income from $20,000 to $30,000 with intervals of $50 for all four statuses. Use a for loop in main and call the computeTax function with appropriate status and income. Save the file as Finals2.cpp

The output needs to look like the image below

Marginal Tax Rate

Single

Married Filing Jointly or Qualifying Widow(er)

Married Filing separately

Head of Household

10%

$0 -$8,350

$0 - $16,700

$0 -$8,350

$0 - $11,950

15%

$8,351 - $33,950

$16,701 - $67,900

$8,351 - $33,950

$11,951 - $45,500

Explanation / Answer

#include<iostream>
using namespace std;
double computeTax(int status, double taxableIncome)
{
double income_tax;
switch(status)
{
case 0:
case 2:
    {
    if(taxableIncome > 8350) income_tax = 8350*0.1+ (taxableIncome-8350)*0.15;
    else income_tax = taxableIncome*0.1;
    }
    break;
case 1:
    {
    if(taxableIncome > 16700) income_tax = 16700*0.1+ (taxableIncome-16700)*0.15;
    else income_tax = taxableIncome*0.1;
    }
    break;
case 3:
    {
    if(taxableIncome > 11950) income_tax = 11950*0.1+ (taxableIncome-11950)*0.15;
    else income_tax = taxableIncome*0.1;
    }
    break;
}
return income_tax;
}

int main()
{
cout<<"Taxable Income" <<" "<< "Single" << " "<<"Married Filing Jointly or Qualifying Widow(er)" << " "<< "Married Filing separately" << " "<< "Head of Household"<< endl;
for(double income=20000; income<=30000; income+=50)
{
cout<< income <<" "<< computeTax(0,income)<< " "<<computeTax(1,income) << " "<<computeTax(1,income)<< " "<< computeTax(2,income)<< endl;
}
return 0;
}