程序博客网 > 哈工大大数据产业集团
来源:互联网 发布:哈工大大数据产业集团 编辑:程序博客网 时间:2024/05/29 11:55
import javax.swing.JOptionPane;//引用javax.swing包里的JOptionPane类/** * 美国的个人所得税时给予纳税人的情况和应征收的收入计算的。 * 纳税人情况共有四种: 单身纳税人、已婚共同纳税人、已婚单缴纳税人和家庭纳税人。 * ------------------------------------------------------------------------------- * 税率单身纳税人已婚共同纳税人已婚单缴纳税人家庭纳税人 * 10%低于等于6000低于等于12000低于等于6000低于等于10000 * 15%6001-2795012001-467006001-2335010001-37450 * 27%27951-6770046701-11285023351-5642537451-96700 * 30%67701-141250112851-17195056426-8597596701-156600 * 35%141251-307050171951-30705085976-153525156601-307050 * 38.6%307051及以上307051及以上153526及以上307051及以上 * ------------------------------------------------------------------------------- * * @author * */public class nan {//新建public的nan类/** * @param args */public static void main(String[] args) {//主方法String statusString = JOptionPane.showInputDialog(null, "输入纳税人身份/n"+ "(0-单身纳税人, 1-已婚共同纳税人,/n" + "2-已婚单缴纳税人, 3-家庭纳税人)", "计算税金 输入:",JOptionPane.QUESTION_MESSAGE);//输入提示框,要求输入0,1,2,3,4,数字代表不同的纳税人int status = Integer.parseInt(statusString);//将输入烦人字符串强制转换成integer类型// Prompt the user to enter taxable incomeString incomeString = JOptionPane.showInputDialog(null, "输入须纳税的收入:",//输入提示框,"计算税金 输入:", JOptionPane.QUESTION_MESSAGE);//我发现并没有这个计算税金的提示框double income = Double.parseDouble(incomeString);//将收入类型从String类型强制转换为double类型// Compute taxdouble tax = 0;//定义一个double类型税金变量tax为0//+++++++++++++++++++++++++++++++++++++++//if (status == 0) { // Compute tax for single filers//首要前提如果纳税人为单身纳税人if (income <= 6000)//single的收入小于或等于6000tax = income * 0.10;//税金等于收入的10%else if (income <= 27950)//single的收入小于等于27950tax = 6000 * 0.10 + (income - 6000) * 0.15;//税金等于收入高于6000部分的15%加上6000的税金else if (income <= 67700)//single的收入小于等于67700tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (income - 27950)* 0.27;else if (income <= 141250)//single的收入小于141250tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950)* 0.27 + (income - 67700) * 0.30;else if (income <= 307050)//single的收入小雨307050tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950)* 0.27 + (141250 - 67700) * 0.30 + (income - 141250)* 0.35;else//其他情况tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950)* 0.27 + (141250 - 67700) * 0.30 + (307050 - 141250)* 0.35 + (income - 307050) * 0.386;} //+++++++++++++++++++++++++++++++//else if (status == 1) { // Compute tax for married file jointly// Left as exercise//纳税人为已婚共同纳税人if (income <= 12000)tax = income * 0.10;else if (income <= 46700)tax = 6000 * 0.10 + (income - 12000) * 0.15;else if (income <= 112850)tax = 6000 * 0.10 + (46700 - 12000) * 0.15 + (income - 46700)* 0.27;else if (income <= 171950)tax = 6000 * 0.10 + (46700 - 12000) * 0.15 + (112850 - 46700)* 0.27 + (income - 112850) * 0.30;else if (income <= 307050)tax = 6000 * 0.10 + (46700 - 12000) * 0.15 + (67700 - 46700)* 0.27 + (171950 - 112850) * 0.30 + (income - 171950)* 0.35;elsetax = 6000 * 0.10 + (27950 - 12000) * 0.15 + (67700 - 46700)* 0.27 + (141250 - 112850) * 0.30 + (307050 - 171950)* 0.35 + (income - 307050) * 0.386;} //+++++++++++++++++++++++++++++++//else if (status == 2) { // Compute tax for married separately// Left as exercise//如果纳税人为已婚单缴纳税人if (income <= 6000)tax = income * 0.10;else if (income <= 23350)tax = 6000 * 0.10 + (income - 6000) * 0.15;else if (income <= 56425)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (income - 23350)* 0.27;else if (income <= 85975)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350)* 0.27 + (income - 56425) * 0.30;else if (income <= 153525)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350)* 0.27 + (85975 - 56425) * 0.30 + (income - 85975)* 0.35;elsetax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350)* 0.27 + (85975 - 56425) * 0.30 + (153525 - 85975)* 0.35 + (income - 153525) * 0.386;} //+++++++++++++++++++++++++++++++//else if (status == 3) { // Compute tax for head of household// Left as exercise//如果是家庭纳税人if (income <= 10000)tax = income * 0.10;else if (income <= 37450)tax = 6000 * 0.10 + (income - 10000) * 0.15;else if (income <= 96700)tax = 6000 * 0.10 + (37450 - 10000) * 0.15 + (income - 37450)* 0.27;else if (income <= 156600)tax = 6000 * 0.10 + (37450 - 10000) * 0.15 + (96700 - 37450)* 0.27 + (income - 96700) * 0.30;else if (income <= 307050)tax = 6000 * 0.10 + (37450 - 10000) * 0.15 + (67700 - 37450)* 0.27 + (156600 - 96700) * 0.30 + (income - 156600)* 0.35;elsetax = 6000 * 0.10 + (27950 - 10000) * 0.15 + (67700 - 37450)* 0.27 + (141250 - 96700) * 0.30 + (307050 - 156600)* 0.35 + (income - 307050) * 0.386;} //+++++++++++++++++++++++++++++++++++++++//else {//上面的if全部不符合的话System.out.println("错误: 不合法的身份!");//则输出"错误:不合法的身份!"System.exit(0);//程序运行的这里弹出}// Display the resultJOptionPane.showMessageDialog(null, "税金是:" + (int) (tax * 100) / 100.0,"计算税金 输出:", JOptionPane.INFORMATION_MESSAGE);//输出税金,将整型转换为Double,这句需要解释一下}}