作如下假设:
a. 基本工资等级=10.00美元/小时
b. 甲板(超过40小时)=1.5倍的小时
c. 税率 前300美元为15%
下一个150美元为20%
余下的为25%
用#define定义常量,不必关心本例是否符合当前的税法。
补充:自定义增加了循环,#退出。
#include <stdio.h>
#define JBGZ 10
#define JB 40
#define JBL 1.5
#define SLZ1 300
#define SLZ2 450
#define SL1 0.15
#define SL2 0.2
#define SL3 0.25
int main(void)
{
int n, money;
float sl, jgz;
printf("请输入您工作的时间(# to quit): ");
while(scanf("%d", &n) == 1)
{
if(n == '#')
break;
if(n <= 40)
money = n * JBGZ;
else
money = ((n - 40) * JBL + 40) * JBGZ;
if(money <= SLZ1)
sl = money * SL1;
else if( money <= SLZ2)
sl = (money - SLZ1) * SL2 + 300 * SL1;
else if( money > SL2)
sl = (money -SLZ2) * SL3 + SLZ1 * SL1 + (SLZ2 -SLZ1) * SL2;
jgz = money - sl;
printf("您工资总额为%d,税金为%.2f,净工资为%.2f.\n", money, sl, jgz);
printf("请输入您工作的时间: \n");
}
return 0;
}