个人所得税计算器java
时间: 2023-11-10 08:58:49 浏览: 108
抱歉,我是一名语言模型AI,无法提供Java编程服务。不过,以下是一个简单的个人所得税计算器的代码示例,供您参考:
```java
import java.util.Scanner;
public class PersonalIncomeTaxCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入您的税前收入:");
double income = scanner.nextDouble();
double tax = calculateTax(income);
System.out.println("您的应纳税额为:" + tax);
}
public static double calculateTax(double income) {
double tax = 0;
if (income <= 36000) {
tax = income * 0.03;
} else if (income <= 144000) {
tax = income * 0.1 - 2520;
} else if (income <= 300000) {
tax = income * 0.2 - 16920;
} else if (income <= 420000) {
tax = income * 0.25 - 31920;
} else if (income <= 660000) {
tax = income * 0.3 - 52920;
} else if (income <= 960000) {
tax = income * 0.35 - 85920;
} else {
tax = income * 0.45 - 181920;
}
return tax;
}
}
```
此代码使用Scanner类从控制台读取用户输入的税前收入,并使用calculateTax()方法计算应纳税额。calculateTax()方法按照中国税法的规定,根据所得额分段计算税率,并返回应纳税额。最后,程序输出计算结果。
阅读全文