Tuesday, September 8, 2009

Homework 2: Taxes

For this homework you will implement a program that calculates the federal taxes that a single person in the US must pay given her gross income. This homework is due Tuesday September 15 @noon. Like many countries, the US uses tax brackets to calculate the taxes a person must pay. The steps to calculate the tax amount are the following: (also see the wikipedia explanation)

  1. Start with the gross income, subtract $5,700 from it. This is the new income value.
  2. Use the table below and apply the various marginal tax rates depending on the person's new income value:
    IncomeMarginal Tax Rate
    <= $835010%
    $8,351– $33,95015%
    $33,951 – $82,25025%
    $82,251 – $171,55028%
    $171,551 – $372,95033%
    $372,951+35%

For example, if the income is $20,000, then we first subtract $5700 to get $14,300. Of this we have to pay 10% for the first $8,350, which works out to be $835, plus 15% of ($14,300 - $8,350) which is $892. So the total tax is $835 + $892 = $1,727.

So, your program will ask the user to enter the income and then print out the tax, as such:

Please enter income: 20000
Your taxes are $1727.

Please think carefully about this program before you start coding it. Remember, the homework is due Tuesday September 15 @noon. Please email it to your TA when you are done.

2 comments:

Timothy said...

should we typecast doubles as integers? Because (14,300 - 8,350)*.15 is 892.5, should we ignore the 50 cents?

Also, because 10% of 8350 is 835, shouldn't it be $835 + $892 = $1727? not 825 + $892 = $1,717? or maybe I'm just missing something?

Jose M Vidal said...

Yes, ignore cents, the IRS does. And, its OK to use integers. I assume anyone making more than 1.2billion will have her own accountant.

I've fixed the $825 typo.