朝鲜蓟 甜菜 胡萝卜 按规则计算价格以及运费(图)


#include "stdAfx.h"
#include "ctype.h" //需要调用tolower函数
#include "stdlib.h"
#define CXJ 1.25 //朝鲜蓟的售价
#define TC 0.65 //甜菜的售价
#define HLB 0.89 //胡萝卜的售价
#define ONEHUI 0.05 //100美元的优惠
#define DOWNHUI 3.50 //五磅以下的订单收取的装卸费
#define MEDHUI 10.00 //超过五磅不足二十磅收取的装卸费
#define BIGHUI 0.1//20磅或以上的运输在8美元的基础上每磅加收0.1美元

int main(void)
{
	char ch;
	double sum=0.0,ave=0.0,cxj=0.0,tc=0.0,hlb=0.0;

	printf("Please input a to c for Purchase:\n");
	printf("a is artichoke Selling price 1.25$\tb is Beet Selling price 0.65$\nc is Carrot Selling price 0.89$\t\tq to quit\n:");
	while((ch=tolower(getchar()))!='q')
	{
		switch(ch)	
		{
			case 'a':printf("You want to buy a number of Artichoke : ");
				scanf("%lf",&cxj);
				printf("Enter the Q exit Input a, b, c continues to : ");continue;
			case 'b':printf("You want to buy a number of Beet : ");
				scanf("%lf",&tc);
				printf("Enter the Q exit Input a, b, c continues to : ");continue;
			case 'c':printf("You want to buy a number of Carrot : ");
				scanf("%lf",&hlb);
				printf("Enter the Q exit Input a, b, c continues to : ");continue;
			default :break; 
		}

	}

		ave=(cxj*CXJ+tc*TC+hlb*HLB);
		sum=(cxj+tc+hlb);

		if(sum<5)
			ave+=DOWNHUI;
		else if(sum>5&&sum<20)
			ave+=MEDHUI;
		else if(sum>=20&&sum<100)
			ave=sum*0.1+8;

		if(ave>=100)
			printf("Your cost is : %0.2lf\n",ave-ave*ONEHUI);
		else
			printf("Your cost is : %0.2lf\n",ave);

	system("pause");

	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值