The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 3.2 shows the rates for 2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So, your tax is $1,082.5.
Create an enum names FilingStatus to hold the four statuses;
Create a reference type to hold all the values - note we would actually read this data from a database.
publci classTaxValues {
public const int Single10 = 8350;
public const int Single15 = 33950;
//...
}
Create a class with the following
Fields - fillingStatus, taxVaues, income, taxOwed
Properties - Encapsulate all fields - what should be private and what should be public (this decision is called Abstraction)
- validate the income passed in. It should be a positive value - if not throw ArgumentException
Constructor - Single constructor that takes a FillingStatus object a TaxValue object and a double (income)
Methods - CalculateTax, overide ToString
Table 1
2009 U.S. Federal Personal Tax Rates
Marginal Tax Rate
Single
Married Filing Jointly or Qualified Widow(er)
Married Filing Separately
Head of Household
10%
$0 – $8,350
$0 – $16,700
$0 – $11,950
15%
$8,351– $33,950
$16,701 – $67,900
$8,351 – $33,950
$11,951 – $45,500
25%
$33,951 – $82,250
$67,901 – $137,050
$33,951 – $68,525
$45,501 – $117,450
28%
$82,251 – $171,550
$137,051 – $208,850
$68,525 – $104,425
$117,451 – $190,200
33%
$171,551 – $372,950
$208,851 – $372,950
$104,426 – $186,475
$190,201 - $372,950
35%
$372,951+
$186,476+
Throughly test your data - pass in bad data (negative income) to make sure you catch it.