#include<stdio.h>
#define H_WAGE1 8.75
#define H_WAGE2 9.33
#define H_WAGE3 10.00
#define H_WAGE4 11.20
#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
,H_WAGE
;
int choice
;
printf("*****************************************************************\n");
printf("Enter the number corresponding to the desired pay rate or action:\n") ;
printf("(1)$8.75/hr (2)$9.33/hr\n");
printf("(3)$10.00/hr (4)$11.20/hr\n");
printf("(5)quit\n");
printf("*****************************************************************\n");
printf("Enter the choice:\n");
scanf("%d",&choice
);
if(choice
==1||choice
==2||choice
==3||choice
==4||choice
==5)
{
switch(choice
)
{
case 1:
H_WAGE
=H_WAGE1
;
printf("Your choice is 1,$8.75/hr.\n");
break;
case 2:
H_WAGE
=H_WAGE2
;
printf("Your choice is 2,$9.33/hr.\n");
break;
case 3:
H_WAGE
=H_WAGE3
;
printf("Your choice is 3,$10.00/hr.\n");
break;
case 4:
printf("Your choice is 4,$11.20/hr.\n");
H_WAGE
=H_WAGE4
;
break;
case 5:
printf("Your choice is 5,to quit.\n");
H_WAGE
=0;
break;
default:
printf("Enter the right number.\n");
break;
}
}
else
printf("Enter the right number.\n");
while(H_WAGE
!=0)
{
printf("Please enter the working time per week:\n");
while(scanf("%f",&time
)==1)
{
if(time
>=0)
{
if(time
<=TIME1
)
{
total
=time
*H_WAGE
;
tax
=total
*RATE1
;
}
else if(time
<TIME2
)
{
total
=time
*H_WAGE
;
tax
=TIME1
*H_WAGE
*RATE1
+(time
-TIME1
)*H_WAGE
*RATE2
;
}
else
{
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");
H_WAGE
=0;
}
}
printf("Done!\n");
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-36845.html