C primer plus 第七章 练习7:编写程序,要求输入一周的工作小时数,然后打印工资总额,税金以及净工资。

#include<stdio.h>
void main(){
double cash,time1,time2,s,j;//工资,正常工作时间,加班时间,税金,净工资。
printf("请输入你的正常工作时间:");
scanf("%lf",&time1);
printf("请输入你的加班工作时间:");
scanf("%lf",&time2);
if(time1>0&&time2>=0)
{
if(time2>40)
cash=10.00*time1+time2*1.5*10.00;
else 
cash=10.00*(time1+time2);
if(cash<300)
{
	s=0.15*cash;
	j=cash-s;
}
else if(cash<=450)
{
s=300*0.15+(cash-300)*0.2;j=cash-s;
}
else
s=(cash-450)*0.25;j=cash-s;
printf("你的工资是%.2f\n你的税金是%.2f\n净收入是%.2f",cash,s,j);
}
else {
printf("请重新输入你的正常工作时间:");
scanf("%lf",&time1);
printf("请重新输入你的加班工作时间:");
scanf("%lf",&time2);
}
}
发布了3 篇原创文章 · 获赞 2 · 访问量 31

猜你喜欢

转载自blog.csdn.net/qq_44720864/article/details/105128037