java输入一个职工的月薪salary,输出应交的个人所得税tax。 tax+=+rate+*+(salary-850) 当+salary+<=+850+时,rate+=+0%; 当+850+<+sa
时间: 2023-11-15 19:07:19 浏览: 113
一个用java写的个人所得税计算程序
5星 · 资源好评率100%
据提供的引用内容,这是一个C语言的代码示例,而不是Java。以下是Java的代码示例:
```
import java.util.Scanner;
public class TaxCalculator {
public static void main(String[] args) {
double salary, rate, tax = 0;
Scanner input = new Scanner(System.in);
salary = input.nextDouble();
if (salary <= 1500) {
rate = 0.03;
tax = rate * salary;
} else if (salary <= 4500) {
rate = 0.10;
tax = rate * (salary - 1500) + 45;
} else if (salary <= 9000) {
rate = 0.20;
tax = rate * (salary - 4500) + 345;
} else {
rate = 0.25;
tax = rate * (salary - 9000) + 1245;
}
System.out.printf("tax=%.2f", tax);
}
}
```
阅读全文