In: Computer Science
The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses (in this program we’ll use only three): single filers, married filing jointly, and head of household. The tax rates vary every year. Table 1 shows the rates for 2016. If you are, say, single with a taxable income of $10,000, the first $9,075 is taxed at 10% and the other $925 is taxed at 15%. So, your tax is $1,046.25.
Table 1. 2014 Taxable Income Brackets and Rates
Rate
Single Filers
Married Joint Filers
Head of Household Filers
10%
$0 to $9,075
$0 to $18,150
$0 to $12,950
15%
$9,076 to $36,900
$18,151 to$73,800
$12,951 to $49,400
25%
$36,901 to $89,350
$73,801 to $148,850
$49,401 to $127,550
28%
$89,351 to $186,350
$148,851 to $226,850
$127,551 to $206,600
33%
$186,351 to $405,100
$226,851 to $405,100
$206,601 to $405,100
35%
$405,101 to 406,750
$405,101 to 457,600
$405,101 to $432,200
39.6%
$406,751+
$457,601+
$432,201+
Source: Internal Revenue Service
Part I:
You are to re-write programming assignment 1 to compute personal income tax. Your program should prompt the user to enter the filing status and taxable income and compute the tax. Enter 0 for single filers, 1 for married filing jointly, and 2 for head of household.
Part II:
In this part of the assignment, you will reorganize your code using Methods. Your program must have at least four (4) methods i.e the main method, and the other three (3) for tax brackets that return the tax amount owed. You will organize the income ranges as an Array in each method and select an Array Record to compute specific tax in a tax bracket.
Part III
i) You are required to follow the Software Development Process (Ref: Chapter 2.16).
ii) Must include a Design Diagram [Ref: Fig. 6.11]
iii) Use UML [Ref: Fig 9.4] create class diagrams for your program
NOTE
There will be NO POINTS earned even if your code is working if you
1. don’t use methods
2. don’t use arrays
Hence you will get a 0/50.
Deliverables:
Note:
· Project name: ProgrammingAssignment_2
· Class name: ProgrammingAssignment_2
if (status == 0) { // Compute tax for single filers } else if (status == 1) { // Compute tax for married filing jointly } else if (status == 2) { // Compute tax for married filing separately } else if (status == 3) { // Compute tax for head of household } else { // Display wrong status }For each filing status there are six tax rates. Each rate is applied to a certain amount of taxable income. For example, of a taxable income of $400,000 for single filers, $8,350 is taxed at 10%, (33,950 - 8,3502) at 15%, (82,250 - 33,950), at 25%(171,550 - 82,250) at 28%, (372,950 - 171,550) at 33%, (400,000 - 372,950)and at 35%.
public class Assignment3TanhaIslam { |
12 |
13 | /** |
14 | * @param args the command line arguments |
15 | */ |
16 | public static void main(String[] args) { |
17 | Scanner input = newScanner(System.in); |
18 | promt |
19 | int status = input.nextint(); |
20 | PromtIncome |
21 | int status = input.nextint(); |
22 |
23 | // Prompt the user to enter filing status |
24 | String statusString = JOptionPane.showInputDialog( |
25 | "Enter the filing status:\n" + |
26 | "(0-single filer, 1-married jointly,\n" + |
27 | "2-married separately, 3-head of household)"); |
28 | int status = input.nextInt(); |
29 |
30 | // Prompt the user to enter taxable income |
31 | String incomeString = JOptionPane.showInputDialog( |
32 | "Enter the taxable income:"); |
33 | double income = input.nextDouble(); |
34 |
35 | // Compute tax |
36 |
37 | if(status==0) |
38 | { // Compute tax for single filers |
39 | if (income <= 8350) |
40 | tax = income * 0.10; |
41 | else if (income <= 33950) |
42 | tax = 8350 * 0.10 + (income - 8350) * 0.15; |
43 | else if (income <= 82250) |
44 | tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25; |
45 | else if (income <= 171550) |
46 | tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28; |
47 | else if (income <= 372950) |
48 | tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + |
49 | (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + |
50 | (income - 171550) * 0.33; |
51 | else |
52 | tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; |
53 | } |
54 | else if(status==1) |
55 | { // Compute tax for married file jointly |
56 | // Left as exercise |
57 | } |
58 | else if (status == 2) |
59 | { // Compute tax for married separately |
60 | // Left as exercise |
61 | } |
62 | else if (status==3) |
63 | { // Compute tax for head of household |
64 | // Left as exercise |
65 | } |
66 | else |
67 | { |
68 |
69 | System.out.println("Error: invalid status"); |
70 |
71 | } |
72 |
73 | // Display the result |
74 | JOptionPane.showMessageDialog(null, "Tax is " + (int)(tax * 100) / 100.0); |
75 | } |
76 | } |