当前位置:首页 » 编程语言 » c语言计税
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言计税

发布时间: 2023-08-23 18:54:59

Ⅰ 求各位大神帮帮忙 c语言怎样使用switch语句来写工资提成

#include<stdio.h>
intmain()
{
floata,b;
printf("请输入销售额:");
scanf("%f",&a);
switch((int)(a/1000))//提取a的千位数字
{
case0:
b=0;
break;
case1:
b=2;
break;
case2:
case3:
case4:
b=5;
break;
default:
if(a==5000.0)//边界情况:销售额等于5000元
b=5;
else
b=10;
break;
}
floattotal=500+500*(b/100);
printf("总工资为:%.2f ",total);
return0;
}

示范对话1:

Ⅱ c语言编写程序,输入月薪数a,计算并输出税率、应缴税款和实得奖金数。工薪所得扣除标

#include <stdio.h>
main()
{
int grade;
float salary,real_salary,ratal,tax;
printf("请输入个人工资薪金所得:\n ");
scanf("%f", &salary);
if(salary<0)
{
printf("输入的数据错误\n");
ratal=0;
tax=0;
}
else if(salary<=2000)
{
ratal=0;
tax=0;
}
else
ratal=salary-2000;
if(ratal<=500)
grade=1;
if(ratal>500 && ratal<=2000)
grade=2;
if(ratal>2000 && ratal<=5000)
grade=3;
if(ratal>5000 && ratal<=20000)
grade=4;
if(ratal>20000 && ratal<=40000)
grade=5;
if(ratal>40000 && ratal<=60000)
grade=6;
if(ratal>60000 && ratal<=80000)
grade=7;
if(ratal>80000 && ratal<=100000)
grade=8;
switch (grade)
{
case 1:tax=ratal*0.05-0;break;
case 2:tax=ratal*0.1-25;break;
case 3:tax=ratal*0.15-125;break;
case 4:tax=ratal*0.2-375;break;
case 5:tax=ratal*0.25-1375;break;
case 6:tax=ratal*0.3-3375;break;
case 7:tax=ratal*0.35-6375;break;
case 8:tax=ratal*0.4-10375;break;
default: tax=ratal*0.45-15375;
}
real_salary=salary-tax;
printf("应纳税额: %.2f元\n",tax);
printf("税后月收入: %.2f元\n",real_salary);
}

Ⅲ C语言计算工资的代码

源代码中,你的if语句里面两个表达式是用逗号分开的,这样并不能满足两个条件都满足的要求
现修改代码如下,

#include<stdio.h>
intmain()
{
inty,t;
doublem;
scanf("%d%d",&y,&t);
if(y<5&&t<=40)//使用&&表示要求两个条件都满足
printf("%.2f",m=t*30);
elseif(y<5&&t>40)
printf("%.2f",m=40*30+(t-40)*30*1.5);
elseif(y>=5&&t<=40)
printf("%.2f",m=t*50);
else
printf("%.2f",m=40*50+(t-40)*50*1.5);
}