-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputeTax.java
More file actions
55 lines (48 loc) · 2.11 KB
/
ComputeTax.java
File metadata and controls
55 lines (48 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;
/**
* Created by Melissa on 17/04/2017.
* PAGE 91 - 92
*/
public class ComputeTax {
public static void main(String[] args) {
// Create a Scanner Object
Scanner input = new Scanner(System.in);
// Prompt the user to enter filing status
System.out.print("Filing Status\n0 - Single Filer\n1 - Married Jointly or Qualifying Widow(er)\n2 - Married Separately\n3 - Head of Household\n\nEnter the filing status: ");
int status = input.nextInt();
// Prompt the user to enter taxable income
System.out.print("Enter the taxable income: ");
double income = input.nextDouble();
// Compute tax
double tax = 0;
if(status == 0){ // Comput tax for single filers
if (income <= 8350)
tax = income * 0.10;
else if (income <= 33950)
tax = 8350 * 0.10 + (income - 8350) * 0.15;
else if (income <= 82250)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
else if (income <= 171550)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
else if (income <= 372950)
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (income - 171550) * 0.33;
else
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
else if (status == 1) { // Left as an exercise
// Compute tax for married file jointly or qualifying widow(er)
}
else if(status == 2) { // Compute tax for married separately
// Left as an exercise
}
else if(status == 3) { // Compute tax for head of household
// Left as an exercise
}
else {
System.out.println("Error: Invalid status");
System.exit(1);
}
// Display the result
System.out.println("Tax is " + (int)(tax * 100) / 100.0);
}
}