Today is Tax Day!
Oops.
Well, today is tax day if you are a resident of Maine or Massachusetts.
So you're probably still completing your return and need a calculator for when you get to Line 44.
Given an input of taxable income (US$, accurate to 2 decimal places) and a string representing filing status, output the amount of tax (also US$ to 2 decimal places).
Filing status will be one of S
, MFJ
, QW
, MFS
, or HH
for Single, Married Filing Jointly, Qualified Widow(er), Married Filing Separately or Head of Household, respectively.
Tax will be calculated according to the official tables in IRS Revenue Procedure 2014-61, section .01 Tax Rate Tables, Tables 1-4. I have added these tables at the bottom of the question.
You may choose whatever rounding method you like, as long as the result is accurate to 2 decimal places.
Example Inputs:
0.00 S
10000.00 MFJ
100000.00 MFS
1000000.00 QW
Example Outputs corresponding to above inputs:
0.00
1000.00
21525.75
341915.90
Summary of tax tables.
Married Filing Jointly and Qualified Widow(er)
Income Interval Tax [ $0, $18450] 10% ( $18450, $74900] $1845 + 15% of the excess over $18450 ( $74900, $151200] $10312.50 + 25% of the excess over $74900 ($151200, $230450] $29387.50 + 28% of the excess over $151200 ($230450, $411500] $51577.50 + 33% of the excess over $230450 ($411500, $464850] $111324 + 35% of the excess over $411500 ($464850, $∞] $129996.50 + 39.6% of the excess over $464850
Head of Household
Income Interval Tax [ $0, $13150] 10% ( $13150, $50200] $1315 + 15% of the excess over $13150 ( $50200, $129600] $6872.50 + 25% of the excess over $50200 ($129600, $209850] $26722.50 + 28% of the excess over $129600 ($209850, $411500] $49192.50 + 33% of the excess over $209850 ($411500, $439000] $115737 + 35% of the excess over $411500 ($439000, $∞] $125362 + 39.6% of the excess over $439000
Single
Income Interval Tax [ $0, $9225] 10% ( $9225, $37450] $922.50 + 15% of the excess over $9225 ( $37450, $90750] $5156.25 + 25% of the excess over $37450 ( $90750, $189300] $18481.25 + 28% of the excess over $90750 ($189300, $411500] $46075.25 + 33% of the excess over $189300 ($411500, $413200] $119401.25 + 35% of the excess over $411500 ($413200, $∞] $119996.25 + 39.6% of the excess over $413200
Married Filing Separately
Income Interval Tax [ $0, $9225] 10% ( $9225, $37450] $922.50 + 15% of the excess over $9225 ( $37450, $75600] $5156.25 + 25% of the excess over $37450 ( $75600, $115225] $14693.75 + 28% of the excess over $75600 ($115225, $205750] $25788.75 + 33% of the excess over $115225 ($205750, $232425] $55662 + 35% of the excess over $205750 ($232425, $∞] $64998.25 + 39.6% of the excess over $232425