#include <stdio.h>
#define WAGES1 8.75
#define WAGES2 9.33
#define WAGES3 10.0
#define WAGES4 11.20
#define OVERTIME 40
#define TAXM_01 300
#define TAXM_02 450
#define TAX1 45
#define TAX2 75
#define TAX_01 0.15
#define TAX_02 0.2
#define TAX_03 0.25
int main () {
int ch;
double time, wages, tax, inc;
printf("*****************************************************************\n");
printf("输入您想要的工资等级(输入5或其他字符退出程序):\n");
printf("1)%-20.2f/hr2)%.2f/hr\n3)%-20.2f/hr4)%.2f/hr\n5)quit\n", WAGES1, WAGES2, WAGES3, WAGES4);
printf("*****************************************************************\n");
while(scanf("%d", &ch) == 1 && ch != 5)
{
printf("请输入您这周的工作时长(请不要超过168小时或小于0小时):");
scanf("%lf", &time);
if(time > 168 || time < 0)
{
printf("您的输入不正确\n");
continue;
}
switch (ch)
{
case 1:if(time>OVERTIME)
wages = OVERTIME * WAGES1 + (time - OVERTIME) * WAGES1 * 1.5;
else
wages = time * WAGES1;
break;
case 2:if(time>OVERTIME)
wages = OVERTIME * WAGES2 + (time - OVERTIME) * WAGES2 * 1.5;
else
wages = time * WAGES2;
break;
case 3:if(time>OVERTIME)
wages = OVERTIME * WAGES3 + (time - OVERTIME) * WAGES3 * 1.5;
else
wages = time * WAGES3;
break;
case 4:if(time>OVERTIME)
wages = OVERTIME * WAGES4 + (time - OVERTIME) * WAGES4 * 1.5;
else
wages = time * WAGES4;
break;
default:printf("输入无效\n");printf("输入您想要的工资等级(输入5退出程序)");continue;
}
if(wages <= TAXM_01)
tax = wages * TAX_01;
if(wages <= TAXM_02)
tax = TAX1 + (wages - TAXM_01) * TAX_02;
else
tax = TAX2 + (wages - TAXM_02) * TAX_03;
inc = wages - tax;
printf("您这周的工作时长是%.2lf,工资是%.2lf,税金是%.2lf,净收入是%.2lf\n",
time, wages, tax, inc);
printf("输入您想要的工资等级(输入5退出程序)");
}
printf("再见!");
return 0;
}