public class Test { public static void main(String[] args){ //程序说明:计算所有婚姻状态人的税款 //提示用户输入 Scanner input = new Scanner(System.in); System.out.println("0-single filer,1-married jointly&nbs***bsp;qualifying widow(er)"); System.out.println("2-married separately,3-head of household)"); //输入登记的身份 System.out.print("Enter the filing status:"); int s = input.nextInt(); //输入可征税收入 System.out.print("Enter the taxable income:"); double income = input.nextDouble(); //计算并显示该人应交的税款 double tax = 0; if(s == 0){ if(income <= 8350) tax =income * 0.1; else if(income <= 33950 ){ tax = 8350 * 0.1 + (income - 8350) * 0.15; } else if(income <= 82250) tax = (8350 * 0.1) + ((33950 - 8350) * 0.15) + (income - 33950) * 0.25 ; else if(income <= 171550) tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (52250 - 33950)* 0.25 + (income - 52250) * 0.28; else if(income <= 372950) tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250)* 0.28 + (income - 171550) * 0.33; else tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; System.out.println("Tax is " + tax); } else if(s == 1){ if(income <= 16700) tax = income * 0.10; else if(income <= 67900 ) tax = 16700 * 0.1 + (income - 8350) * 0.15; else if(income <= 137050) tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 ; else if(income <= 208850) tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + (income - 137050) * 0.28; else if(income <= 372950) tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + (208850 - 137050) * 0.28 + (income - 208850) * 0.33; else tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + (208850 - 137050) * 0.28 + (372950 - 208850) * 0.33 + (income - 372950) * 0.35; System.out.println("Tax is " + tax); } else if(s == 2){ if(income <= 8350) tax = income * 0.10; else if(income <= 33950 ) tax = 8350 * 0.1 + (income - 8350) * 0.15; else if(income <= 68525) tax = 8350 * 0.1 + (33950 - 8350)* 0.15 + (income - 33950) * 0.25 ; else if(income <= 104425) tax = 8350 * 0.1 + (33950 - 8350)* 0.15 + (68525 - 33950)* 0.25 + (income - 68525) * 0.28; else if(income <= 186475) tax = 8350 * 0.1 + (33950 - 8350)* 0.15 + (68525 - 33950)* 0.25 + (104425 - 68525) * 0.28 + (income - 104425) * 0.33; else tax = 8350 * 0.1 + (33950 - 8350)* 0.15 + (68525 - 33950)* 0.25 + (104425 - 68525) * 0.28 + (186475 - 104425) * 0.33 + (income - 186475) * 0.35; System.out.println("Tax is " + tax); } else if(s == 3){ if(income <= 11950) tax = income * 0.10; else if(income <= 45500 ) tax = 11950 * 0.1 + (income - 11950) * 0.15; else if(income <= 117450) tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (income - 45500) * 0.25 ; else if(income <= 190200) tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + (income - 117450) * 0.28; else if(income <= 372950) tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + (190200 - 117450) * 0.28 + (income - 190200) * 0.33; else tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + (190200 - 117450) * 0.28 + (372950 - 190200)* 0.33 + (income - 372950) * 0.35; System.out.println("Tax is " + tax); } else System.out.println("error status."); } }