#include <stdio.h>
#include <stdlib.h>
int jishu(double x)
{
if(0<x&&x<=500)
return 1
else if(500<x&&x<=2000)
return 2
else if(2000<x&&x<=5000)
return 3
else if(5000<x&&x<=20000)
return 4
else if(20000<x&&x<=40000)
return 5
else if(40000<x&&x<=60000)
return 6
else if(60000<x&&x<=80000)
return 7
else if(80000<x&&x<=100000)
return 8
else
return 9
}
main()
{
double rate[10]={0.0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45}
int a[10]={0,0,25,125,375,1375,3375,6375,10375,15375}
double n,m,l
int i
printf("请输入工资:")
scanf("%lf",&l)
if(l<=3500)
printf("您不用交税\n")
else
{
n=l-3500.0
i=jishu(n)
m=n*rate[i]-a[i]
printf("应缴个人所得税:%.2lf\n实发工资额:%.2lf\n",m,l-m)
}
}
这是按你说的计算方法
代码文本:
#include "stdio.h"
int main(int argc,char *argv[]){
double x,tax
printf("Please enter the number salary, negative end...\n")
while(scanf("%lf",&x),x>=0){
if(x>=5000)
tax=(x-5000)*0.2+4200*.03
else if(x>=800 &&x<5000)
tax=(x-800)*.03
else
tax=0
printf("You should pay %.2f yuan.\n",tax)
}
return 0
}
程序首先提示用户输入工资,使用 scanf() 函数将用户输入的数据存储到变量 salary 中。然后,使用 if-else 语句
根据税收规定计算税收:如果工资大于5000元,则计算应缴纳的税收((工资-5000)*5%)并减去税收得到税后工资;否则,税收为0,税后工资等于基本工资。最后,程序使用 printf() 函数输出税收和税后工资的值。
、