题目
编写一个程序,提示用户输入一周工作的小时数,然后打印工资总额、税金和净收入。做如下假设:
a.基本工资 = 1000美元/小时
b.加班(超过40小时) = 1.5倍的基本工资
c.税率: 前300美元为15%,续150美元为20%,余下的为25%
编程
#include <stdio.h>
//定义税率
#define TAX_1 0.15
#define TAX_2 0.20
#define TAX_3 0.25
int main(void)
{
int WorkTimes;
int BaseWage, OverTimesWage, AllWage;
float TaxWage;
float Income;
printf("please input worktimes:");
scanf("%d", &WorkTimes);
//计算总工资
if (WorkTimes <= 40)
{
BaseWage = WorkTimes * 1000;
OverTimesWage = 0;
}
else
{
BaseWage = 40 * 1000;
OverTimesWage = (WorkTimes - 40) * 1500;
}
AllWage = BaseWage + OverTimesWage; //缴税前总工资
printf("your all wage is: %d dollar\n", AllWage);
//计算税金
if (AllWage <= 300)
{
TaxWage = AllWage * TAX_1;
}
else if (AllWage > 300 && AllWage <= 450)
{
TaxWage = (300 * TAX_1) + ((AllWage - 300) * TAX_2);
}
else if (AllWage > 450)
{
TaxWage = (300 * TAX_1) + (150 * TAX_2) + ((AllWage - 450) * TAX_3);
}
printf("your tax wage is: %0.2f dollar\n", TaxWage);
//计算交税后收入
Income = AllWage - TaxWage;
printf("your income is: %0.2f dollar\n", Income);
return 0;
}