c++ 输入一个职工的月薪salary,税率rate,输出应交的个人所得税tax(保留2位小数).计算方式:tax = rate * (salary-850)/100当 salary ≤850 时,rate = 0;当 850 < salary ≤ 1350 时,rate = 5;当 1350 < salary≤ 2850
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 03:16:19
c++ 输入一个职工的月薪salary,税率rate,输出应交的个人所得税tax(保留2位小数).计算方式:tax = rate * (salary-850)/100当 salary ≤850 时,rate = 0;当 850 < salary ≤ 1350 时,rate = 5;当 1350 < salary≤ 2850
c++ 输入一个职工的月薪salary,税率rate,输出应交的个人所得税tax(保留2位小数).
计算方式:tax = rate * (salary-850)/100
当 salary ≤850 时,rate = 0;
当 850 < salary ≤ 1350 时,rate = 5;
当 1350 < salary≤ 2850 时,rate = 10;
当 2850 < salary ≤ 5850 时,rate = 15;
当 5850 < salary 时,rate = 20;
c++ 输入一个职工的月薪salary,税率rate,输出应交的个人所得税tax(保留2位小数).计算方式:tax = rate * (salary-850)/100当 salary ≤850 时,rate = 0;当 850 < salary ≤ 1350 时,rate = 5;当 1350 < salary≤ 2850
楼上用if else 语句写的,我用switch语句写了个,看楼主想用那种方式了,可能有漏洞望楼主指出,谢了
#include
void main()
{
int salary,a;
double tax,rate;
printf("please input a worker'salary!");
scanf("%d",&salary);
a=(salary-1)/500;// -1是为了不重叠
switch(a)
{
case 0:rate=0;break;
\x05 case 1:rate=5;break;
case 2:
case 3:rate=10;break;
case 4:
case 5:
case 6:
\x05 case 7:
case 8:
\x05 case 9:rate=15;break;
\x05 default:rate=20;break;
}
tax=rate * (salary-850)/100;
printf("%3.2f",tax);
printf("\n");
}