练习四

/*编写一个程序,提示用户输入一周的工作小时数,然后打印工资总数,税金和净收入
  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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值