编写个人所得税计算程序

描述

个人所得税是国家对本国公民、居住在本国境内的个人的所得和境外个人来源于本国的所得征收的一种所得税。假设某地区的起征点为3500元(即月工资低于3500时不需要缴纳个人所得税),个人所得税的计算公式为:应纳税额=(工资薪金所得-扣除数)×适用税率-速算扣除数。其中,扣除数为3500元,适用税率以及速算扣除数如下表所示(注:此表并非当前国家个人所得税缴纳标准表,且为简化逻辑个人所得税的计算方式也进行了一定修改)

表-1 个人所得税缴纳标准

全月应纳税所得额

税率

速算扣除数(元)

不超过1500元

3%

0

超过1500元至4500元

10%

105

超过4500元至9000元

20%

555

超过9000元至35000元

25%

1005

超过35000元至55000元

30%

2755

超过55000元至80000元

35%

5505

超过80000元

45%

13505

上表中的全月应纳税所得额=工资薪金所得-扣除数。

现在请你新建三个employee对象小明,小军和小红,他们的月工资分别为2500,8000,100000。并将他们按照顺序存入集合中。遍历集合并计算他们应缴纳的个人所得税(个人所得税为double类型,保留一位小数)。

输入描述:

输出描述:

小明应该缴纳的个人所得税是:xxx
小军应该缴纳的个人所得税是:xxx
小红应该缴纳的个人所得税是:xxx
import java.util.*;

public class Account {
    public static void main(String[] args) {
        List<Employee> employees = new ArrayList<>();
        employees.add(new Employee("小明", 2500));
        employees.add(new Employee("小军", 8000));
        employees.add(new Employee("小红", 100000));
        for(Employee e : employees){
            double tax = 0;
            double income = e.getSalary() - 3500;
            if(income <= 0)
                tax = 0;
            else if(income <= 1500)
                tax = income * 0.03;
            else if(income <= 4500)
                tax = income * 0.1 - 105;
            else if(income <= 9000)
                tax = income * 0.2 - 555;
            else if(income <= 35000)
                tax = income * 0.25 - 1005;
            else if(income <= 55000)
                tax = income * 0.3  - 2755;
            else if(income <= 80000)
                tax = income * 0.35 - 5505;
            else
                tax = income * 0.45 - 13505;
            System.out.println(e.getName() + "应该缴纳的个人所得税是:" + String.format("%.1f", tax));
        }


    }
    static class Employee{
        private String name;
        private double salary;
        public Employee (String name,double salary){
            this.name = name;
            this.salary = salary;
        }
        public String getName(){
            return name;
        }
        public double getSalary(){
            return salary;
        }

    }
}

 总结:本题也可以用数组来进行存储和运算;示例方法是列表的方法,但总体是一样的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值