#include<stdio.h>
#define H_WAGE 10
#define TIME1 30
#define TIME2 40
#define RATE_T 1.5
#define RATE1 0.15
#define RATE2 0.2
#define RATE3 0.25
#define BREAK1 300
#define BREAK2 450
int main(void)
{
float time,total,tax,net;
printf("Enter the working hours per week:(q to quit)\n");
while(scanf("%f",&time)==1)
{
if(time>=0)
{
if(time<=TIME1)
{
total=time*H_WAGE;
tax=total*RATE1;
}
else if(time>TIME1&&time<TIME2)
{
total=time*H_WAGE;
tax=TIME1*H_WAGE*RATE1+(time-TIME1)*H_WAGE*RATE2;
}
else if(time>=TIME2)
{
time=TIME2+(time-TIME2)*RATE_T;
total=time*H_WAGE;
if(total<BREAK2)
tax=TIME1*H_WAGE*RATE1+(time-TIME1)*H_WAGE*RATE2;
else
tax=TIME1*H_WAGE*RATE1+(BREAK2-BREAK1)*RATE2+(total-BREAK2)*RATE3;
}
net=total-tax;
printf("Time is %.2f hours,total income is %.2f,tax is %.2f,net income is %.2f\n"
,time,total,tax,net);
}
else
printf("Time cannot be negtive.\n") ;
printf("Enter time again or q to quit.\n");
}
printf("Done!\n");
return 0;
}
C Primer Plus 第六版第七章第七题
最新推荐文章于 2024-08-22 23:45:07 发布