Exercise writes a program for computing taxes using arrays. Design a class named Tax to contain the following instance data fields:
Rewrite Listing, ComputeTax.java, using arrays. For each filing status, there are six tax rates. Each rate is applied to a certain amount of taxable income. For example, from the taxable income of $400,000 for a single filer, $8,350 is taxed at 10%, (33,950 - 8,350) at 15%, (82,250 - 33,950) at 25%, (171,550 - 82,550) at 28%, (372,550 - 82,250) at 33%, and (400,000 - 372,950) at 36%. The six rates are the same for all filing statuses, which can be represented in the following array:
double[] rates = {0.10, 0.15, 0.25, 0.28, 0.33, 0.35};The brackets for each rate for all the filing statuses can be represented in a twodimensional array as follows:
int[][] brackets = { {8350, 33950, 82250, 171550, 372950}, // Single filer {16700, 67900, 137050, 20885, 372950}, // Married jointly // -or qualifying widow(er) {8350, 33950, 68525, 104425, 186475}, // Married separately {11950, 45500, 117450, 190200, 372950} // Head of household};Suppose the taxable income is $400,000 for single filers. The tax can be computed as follows:
tax = brackets[0][0] * rates[0] +
(brackets[0][1] – brackets[0][0]) * rates[1] +
(brackets[0][2] – brackets[0][1]) * rates[2] +
(brackets[0][3] – brackets[0][2]) * rates[3] +
(brackets[0][4] – brackets[0][3]) * rates[4] +
(400000 – brackets[0][4]) * rates[5]
Listing



■ int filingStatus: One of the four tax-filing statuses: 0—single filer, 1— married filing jointly or qualifying widow(er), 2—married filing separately, and 3—head of household. Use the public static constants SINGLE_FILER (0), MARRIED_JOINTLY_OR_QUALIFYING_WIDOW(ER) (1), MARRIED_ SEPARATELY (2), HEAD_OF_HOUSEHOLD (3) to represent the statuses.
■ int[][] brackets: Stores the tax brackets for each filing status.
■ double[] rates: Stores the tax rates for each bracket.
■ double taxableIncome: Stores the taxable income.
Provide the getter and setter methods for each data field and the getTax() method that returns the tax. Also provide a no-arg constructor and the constructor Tax(filingStatus, brackets, rates, taxableIncome).
Draw the UML diagram for the class and then implement the class. Write a test program that uses the Tax class to print the 2001 and 2009 tax tables for taxable income from $50,000 to $60,000 with intervals of $1,000 for all four statuses. The tax rates for the year 2009 were given in Table. The tax rates for 2001 are shown in Table.
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 |
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,526 – $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+ | $372,951+ | $186,476+ | $372,951+ |
Tax rate | Single filers | Married filing jointly or qualifying widow(er) | Married filing separately | Head of household |
15% | Up to $27,050 | Up to $45,200 | Up to $22,600 | Up to $36,250 |
27.5% | $27,051–$65,550 | $45,201–$109,250 | $22,601–$54,625 | $36,251–$93,650 |
30.5% | $65,551–$136,750 | $109,251–$166,500 | $54,626–$83,250 | $93,651–$151,650 |
35.5% | $136,751–$297,350 | $166,501–$297,350 | $83,251–$148,675 | $151,651–$297,350 |
39.1% | $297,351 or more | $297,351 or more | $ 148,676 or more | $297,351 or more |
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.