-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSATax.java
More file actions
72 lines (65 loc) · 3.5 KB
/
USATax.java
File metadata and controls
72 lines (65 loc) · 3.5 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.util.Scanner;
public class USATax{
public static void main(String[] args) {
//create Scanner
Scanner input = new Scanner(System.in);
//promt the user to enter filing status
System.out.print("(0- single filter, 1 -marriged jointly or " + "qulalifying wido(er), 2-married separtely, 3 -head of " + "household) Enter the filing status: )");
int status = input.nextInt();
//promt the user to enter taxable income
System.out.print("Enter the taxable income: ");
double income = input.nextDouble();
//computer tax
double tax = 0;
if (status == 0) {
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 + (income - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
} else if (status == 1) {
if (income <= 16700) {
tax = income * 0.10;
} else if (income <= 67900) {
tax = 8350 * 0.10 + (income - 8350) * 0.15;
} else if (income <= 137050) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
} else if (income <= 208850) {
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 + (income - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}
} else if (status == 2) {
if (income <= 8350) {
tax = income * 0.10;
} else if (income <= 33950) {
tax = 8350 * 0.10 + (income - 8350) * 0.15;
} else if (income <= 68525) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
} else if (income <= 104425) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
} else if (income <= 186475) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}else if(status == 3){
if (income <= 8350) {
tax = income * 0.10;
} else if (income <= 33950) {
tax = 8350 * 0.10 + (income - 8350) * 0.15;
} else if (income <= 68525) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
} else if (income <= 104425) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
} else if (income <= 186475) {
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
}else{
System.out.println("Error: invalid status");
}
}
}
}