朝鮮アザミ甘菜ニンジンは規則的に価格と運賃を計算する(図)


#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:
"); printf("a is artichoke Selling price 1.25$\tb is Beet Selling price 0.65$
c is Carrot Selling price 0.89$\t\tq to quit
:"); 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
",ave-ave*ONEHUI); else printf("Your cost is : %0.2lf
",ave); system("pause"); return 0; }