java:个人所得税计算器

eclipse使用Java编写简易版个人所得税计算器

文章目录


前言

计算个人所得税的缴纳情况。用户从控制台输入税前工资额金额,系统根据用户输入的工作金额计算应缴纳的税额

在这里插入图片描述

工资个税的计算公式为:

  • 应纳税额 = (工资薪资所得 - 扣除数)* 适用税率 - 速算扣除数

  • 全月应纳税所得额 = 月工资薪资所得 - 扣除数

  • 2011年9月1日起执行7级超额累进税率:扣除数为3500元

在这里插入图片描述

代码实现

具体代码如下:

package day03;
import java.util.Scanner;

public class IncomeTax {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		System.out.println("请输入税前工资金额(¥):");
		double total = scan.nextDouble();
		if(total < 3500) {
			System.out.println("您不需要缴纳个人所得税!");
		}else if((total - 3500) <= 4500) {
			double tax = (total - 3500) * 3/100;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else if((total - 3500) <= 4500) {
			double tax = (total - 3500) * 10/100 - 105;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else if((total - 3500) <= 9000) {
			double tax = (total - 3500) * 20/100 - 555;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else if((total - 3500) <= 35000) {
			double tax = (total - 3500) * 25/100 - 1005;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else if((total - 3500) <= 55000) {
			double tax = (total - 3500) * 30/100 - 2755;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else if((total - 3500) <= 80000) {
			double tax = (total - 3500) * 35/100 - 5505;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}else {
			double tax = (total - 3500) * 45/100 - 13505;
			System.out.println("您应缴纳:"+tax+"元个人所得税");
		}
		

	}

}

代码优化:

package day03;
import java.util.Scanner;

public class IncomeTax {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		System.out.println("请输入税前工资金额(¥):");
		double total = scan.nextDouble();
		double taxIncome = total - 3500;
		double tax = 0.0;
		if(total < 3500) {
			tax = 0.0;
		}else if(taxIncome <= 4500) {
			tax = taxIncome * 3/100;
		}else if(taxIncome <= 4500) {
			tax = taxIncome * 10/100 - 105;
		}else if(taxIncome <= 9000) {
			tax = taxIncome * 20/100 - 555;
		}else if(taxIncome <= 35000) {
			tax = taxIncome * 25/100 - 1005;
		}else if(taxIncome <= 55000) {
			tax = taxIncome * 30/100 - 2755;
		}else if(taxIncome <= 80000) {
			tax = taxIncome * 35/100 - 5505;
		}else {
			tax = taxIncome * 45/100 - 13505;
		}
		System.out.println("您应缴纳:"+tax+"元个人所得税");
		

	}

}

  • 12
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,下面是一个使用 Java 实现个税计算器的示例代码: ```java import java.util.Scanner; public class IncomeTaxCalculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("请输入税前工资:"); double salary = scanner.nextDouble(); System.out.print("请输入社保公积金:"); double socialSecurity = scanner.nextDouble(); System.out.print("请输入专项扣除:"); double deduction = scanner.nextDouble(); double taxableIncome = salary - socialSecurity - deduction - 5000; double tax = 0; if (taxableIncome <= 0) { tax = 0; } else if (taxableIncome <= 3000) { tax = taxableIncome * 0.03; } else if (taxableIncome <= 12000) { tax = taxableIncome * 0.1 - 210; } else if (taxableIncome <= 25000) { tax = taxableIncome * 0.2 - 1410; } else if (taxableIncome <= 35000) { tax = taxableIncome * 0.25 - 2660; } else if (taxableIncome <= 55000) { tax = taxableIncome * 0.3 - 4410; } else if (taxableIncome <= 80000) { tax = taxableIncome * 0.35 - 7160; } else { tax = taxableIncome * 0.45 - 15160; } System.out.println("应缴纳个人所得税:" + String.format("%.2f", tax) + " 元"); } } ``` 在这个示例代码中,我们使用了 Java 的 Scanner 类来接收用户输入的税前工资、社保公积金和专项扣除等信息,并计算出应缴纳的个人所得税金额。计算个人所得税的公式与 HTML 表单的示例代码中的相同。通过使用 `String.format()` 方法来保留两位小数输出结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小鹿快跑~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值