编写个人所得税计算程序

编写个人所得税计算程序_第1张图片

据题意得:应纳税额 = (月工资 - 起征点)*税率 - 速算扣除数

                                        应纳税所得额

代码及解析 

import java.util.*;
public class HomeWork012 {
    public static void main(String[] args) {

        //创建集合
        List employees = new ArrayList<>();
        //添加元素
        Employee employee1 = new Employee("小明",2500);
        Employee employee2 = new Employee("小军",8000);
        Employee employee3 = new Employee("小红",100000);
        employees.add(employee1);
        employees.add(employee2);
        employees.add(employee3);

        for (int i = 0;i get(i).getPayroll() - 3500;
            if(pay <= 0){
                tax = 0.0;
            }else if(pay <= 1500){
                tax = pay * 0.03 - 0;
            }
            else if(pay <= 4500){
                tax = pay * 0.1 - 105;
            }else if(pay <= 9000){
                tax = pay * 0.2 - 555;
            }else if(pay <= 35000){
                tax = pay * 0.25 - 1005;
            }else if(pay < 55000){
                tax = pay * 0.3 - 2755;
            }else if(pay < 800000){
                tax = pay * 0.35 - 5505;
            }else{
                tax = pay * 0.45 - 13505;
            }

            System.out.println(employees.get(i).getName()+"应该缴纳的个人所得税是"+tax);
        }
    }

    //创建一个父类
    static class Employee{
        private String name;
        private int payroll;
        public Employee(String name,int payroll){
            this.name = name;
            this.payroll = payroll;
        }
        public String getName(){
            return name;
        }
        public int getPayroll(){
            return payroll;
        }
    }
}

你可能感兴趣的:(java,servlet,jvm)