要求使用程序实现个人所得税计算器,实现从键盘录入当月工资收入,输出应缴个人所得税。

工资个税的计算公式为:

应纳税额=(工资薪金所得 -“五险一金”-扣除数)×适用税率-速算扣除数     

扣除标准:个税按3500元/月的起征标准算

我们此处简化五险一金,假设为0,则

如果某人的工资收入为5000元,他应纳个人所得税为:(5000—3500)×3%—0=45(元)。

税率表如下:

要求使用程序实现个人所得税计算器,实现从键盘录入当月工资收入,输出应缴个人所得税。_第1张图片

代码
public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入您的工资:");
        
        double salary = scan.nextDouble();
        double deductionAmount = 3500;//扣除数
        double taxSalary = salary-deductionAmount;//应上税的工资
        double taxRate = 0;//税率
        double quickCalculationDeduction = 0;//速算扣除数
        
        if(taxSalary>0) {
            if(taxSalary<1500) {
                taxRate = 0.03;
                quickCalculationDeduction = 0;
            }else if(taxSalary<4500) {
                taxRate = 0.1;
                quickCalculationDeduction = 105;
            }else if(taxSalary<9000) {
                taxRate = 0.2;
                quickCalculationDeduction = 555;
            }else if(taxSalary<35000) {
                taxRate = 0.25;
                quickCalculationDeduction = 1005;
            }else if(taxSalary<55000) {
                taxRate = 0.3;
                quickCalculationDeduction = 2755;
            }else if(taxSalary<80000) {
                taxRate = 0.35;
                quickCalculationDeduction = 5505;
            }else {
                taxRate = 0.45;
                quickCalculationDeduction = 13505;
            }
            
            double taxPayable = taxSalary*taxRate-quickCalculationDeduction;
            System.out.println("当月应缴纳的税额为:"+taxPayable);
            
        }else {
            System.out.println("您的工资未到达起征点,请继续努力~");
            
        }
        
    }

你可能感兴趣的:(java,开发语言)