问题相关代码,请勿粘贴截图
#include<stdio.h>
#define a0 2.05
#define b0 1.15
#define c0 1.09
int main(void)
{
double pound=0;
double sum=0;
double price=0;
char ch='0';
while(ch!='q'){
printf("which are you want?\n");
scanf("%c",&ch);
switch(ch)
{
case 'a':
printf("how much you want?\n");
scanf("%lf",£);
price=price+pound*a0;
sum=sum+pound;
break;
case 'b':
printf("how much you want?\n");
scanf("%lf",£);
price=price+pound*b0;
sum=sum+pound;
break;
case 'c':
printf("how much you want?\n");
scanf("%lf",£);
price=price+pound*c0;
sum=sum+pound;
break;
default: break;
}
}
if(sum<5){
price=price+6.5;
}else if(sum>5&&sum<20){
price=price+14;
}else{
price=price+(0.5*(sum-20)+14);
}
if(price>100){
price=price*0.95;
}
printf("%lf %lf",sum,price);
return 0;
}
运行结果及报错内容
我想要达到的结果
which are you want 只输出一遍