/*编写一个程序,提示用户输入一周的工作小时数,然后打印工资总数,税金和净收入
a.基本工资=1000美元/小时
b.加班(超过40小时)=1.5倍的时间
c.税率: 前300元为15%
续150美元为20%
余下的为25%
*/
自己写程序还是太粗心,竟然忘了&,还找了好长时间。还是要认真,加油。
如下:
/*编写一个程序,提示用户输入一周的工作小时数,然后打印工资总数,税金和净收入
a.基本工资=1000美元/小时
b.加班(超过40小时)=1.5倍的时间
c.税率: 前300元为15%
续150美元为20%
余下的为25%
*/
#include<stdio.h>
#define FIRST 0.15
#define TWO 0.20
#define THIRD 0.25
int main()
{
float wtime=0;
float num=0;
float tax=0;
float net_value=0;
printf("please imput a week working time:\n");
scanf("%f",wtime);
if(wtime<0)
printf("sorry,please enter a number greater than zero:\n");
else
{
num=1000*wtime; //总值
printf("%f",num);
}
if(num<=300)
tax=FIRST*wtime; //税金
else if(wtime<=450)
tax=TWO*(wtime-300);
else if(wtime>450)
tax=THIRD*(wtime-450);
net_value = num - tax; //净值
printf("num=%f\n,tax=%f\n,net value=%f\n",num,tax,net_value);
return 0;
}
查出错误后:
/*编写一个程序,提示用户输入一周的工作小时数,然后打印工资总数,税金和净收入
a.基本工资=1000美元/小时
b.加班(超过40小时)=1.5倍的时间
c.税率: 前300元为15%
续150美元为20%
余下的为25%
*/
#include<stdio.h>
#define FIRST 0.15
#define TWO 0.20
#define THIRD 0.25
int main()
{
float wtime=0;
float num=0;
float tax=0;
float net_value=0;
printf("please imput a week working time:\n");
scanf("%f",&wtime);
if(wtime<0)
printf("sorry,please enter a number greater than zero:\n");
else
{
num=1000*wtime; //总值
printf("%f",num);
}
if(num<=300)
tax=FIRST*wtime; //税金
else if(wtime<=450)
tax=TWO*(wtime-300);
else if(wtime>450)
tax=THIRD*(wtime-450);
net_value = num - tax; //净值
printf("num=%f\n,tax=%f\n,net value=%f\n",num,tax,net_value);
return 0;
}