| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1335 人关注过本帖
标题:感觉变得挺对的,可编译时提示错误,麻烦翻译一下error和warning,并指点如 ...
只看楼主 加入收藏
天霁
Rank: 2
等 级:论坛游民
帖 子:33
专家分:18
注 册:2015-7-17
结帖率:83.33%
收藏
已结贴  问题点数:12 回复次数:6 
感觉变得挺对的,可编译时提示错误,麻烦翻译一下error和warning,并指点如何修改
1  #include <stdio.h>
2  #include <ctype.h>                              //ABC Mail Order Grocery朝鲜蓟的售价是1.25美元/磅,甜菜的售价是0.65美元/磅,胡萝卜的售价是0.89美元/磅。
3  #define ARTICHOKE 1.25                          // 在添加运输费用之前,他们为满100美元 的订单提供5%的打折优惠。         
4  #define BEET 0.65                               //对5磅或以下的定单收取3.50美元的运输和装卸费用;超过5磅而不足20磅的定单收取1O.OO美元的运输和装卸费用:20磅 或以上的运输,在8美元基础上每磅加收0.1美元。
5  #define CARROT 0.89                            //编写程序,在循环中使用switch语句,以便对输入a的响应是让用户输入所需的朝鲜蓟磅数,b为甜菜 的磅数,c为胡萝卜的磅数,而q允许用户退出订购过程。
6  #define DISCOUNT_LIMIT 100                    //然后程序计算总费用、折扣和运输费用(如果有运输费的话),以及总数。
7  #define DISCOUNT_RATE 0.05                    //随后程序应该显示所有的购买 信息:每磅的费用、订购的磅数、该订单每种蔬菜的费用、订单的总费用、折扣,如果有的话加上运输费用,以及所有费用的总数。
8  #define FREIGHT_FEE1 3.5                           
9  #define FREIGHT_LIMIT1 5
10 #define FREIGHT_FEE2 10
11 #define FREIGHT_LIMIT2 20
12 #define FREIGHT_FEE3 8
13 #define FREIGHT_RATE3 0.1
14 int main(void)
15 {
16    char ch;
17    double artichoke=0,beet=0,carrot=0;
18    double sum,discount,freight;
19    printf("Please select your vegetables\n");
20    printf("a.artichoke:$%.2f\n",ARTICHOKE);
21    printf("b.beet:$%.2f\n",BEET);
22    printf("c.carrot:$%.2f\n",CARROT);
23    printf("q.quit\n");
24    printf("price as dollars per pound\n");
25    while((ch=tolower(getchar())!='q')
26    {
27      switch(ch)
28      {
29        case'a':printf("How many pounds of artichoke do you want?\n");
30                      scanf("%lf",&artichoke);
31                      printf("please select your vegetables:a.b.c.q\n");
32                      continue;
33        case'b':printf("How many pounds of artichoke do you want?\n");
34                      scanf("%lf",&beet);
35                      printf("please select your vegetables:a.b.c.q\n");
36                     continue;
37        case'c':printf("How many pounds of artichoke do you want?\n");
38                      scanf("%lf",&carrot);
39                      printf("please select your vegetables:a.b.c.q\n");
40                      continue;
41        default:break;
42      }
43     }
44    printf("%10s%10s%10s%10s\n"," ","artichoke","beet","carrot");
45    printf("%10s%10.2lf%10.2lf%10.2lf\n","price",ARTICHOKE,BEET,CARROT);
46    printf("%10s%10.2lf%10.2lf%10.2lf\n","pound",artichoke,beet,carrot);
47    printf("%10s%10.2lf%10.2lf%10.2lf\n",charge,ARTICHOKE*artichoke,BEET*beet,CARROT*carrot);
48    sum=ARTICHOKE*artichoke+BEET*beet+CARROT*carrot;
49    if(sum<100)discount=0;
50    else discount=sum*DISCOUNT_RATE;
51    if(artichoke+beet+carrot<FREIGHT_LIMIT1)freight=FREIGHT_FEE1;
52    else if(artichoke+beet+carrot<FREIGHT_LIMIT2)freight=FREIGHT_FEE2;
53        else freight=8+(artichoke+beet+carrot-FREIGHT_LIMIT2)*FREIGHT_RATE3;
54    sum=sum-dicount+freight;
55   printf("the price each pound:%.2f\n",sum/(artichoke+beet+carrot));
56    printf("the pound:%.2f\n",artichoke+beet+carrot);
57    printf("the sum:%.2f\n",sum);
58    printf("discount:%.2f\n",discount);
59    return 0;
60  }

||=== Build: Debug in ABCMail (compiler: GNU GCC Compiler) ==
In function 'main':|
26|error: expected ')' before '{' token|
60|error: expected expression before '}' token|
18|warning: unused variable 'freight' [-Wunused-variable]|
18|warning: unused variable 'discount' [-Wunused-variable]|
18|warning: unused variable 'sum' [-Wunused-variable]|
17|warning: unused variable 'carrot' [-Wunused-variable]|
17|warning: unused variable 'beet' [-Wunused-variable]|
17|warning: unused variable 'artichoke' [-Wunused-variable]|
60|warning: control reaches end of non-void function [-Wreturn-type]|
||=== Build failed: 2 error(s), 7 warning(s) (0 minute(s), 0 second(s)) ===|
搜索更多相关主题的帖子: 胡萝卜 include warning 运输费用 打折优惠 
2015-08-09 20:52
kenierlee
Rank: 6Rank: 6
等 级:侠之大者
威 望:3
帖 子:58
专家分:474
注 册:2015-7-28
收藏
得分:4 
25    while((ch=tolower(getchar())!='q'))
2015-08-09 21:18
天霁
Rank: 2
等 级:论坛游民
帖 子:33
专家分:18
注 册:2015-7-17
收藏
得分:0 
回复 2楼 kenierlee
为什么还要加个‘)’括号不是都齐了吗?
2015-08-10 06:31
hjx1120
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:李掌柜
等 级:贵宾
威 望:41
帖 子:1314
专家分:6927
注 册:2008-1-3
收藏
得分:8 
楼主在仔细看看,真的是右括号和右括号对齐的嘛
2015-08-10 06:35
天霁
Rank: 2
等 级:论坛游民
帖 子:33
专家分:18
注 册:2015-7-17
收藏
得分:0 
回复 4楼 hjx1120
哦,我刚看见,明白了,谢谢,码太多,有时候容易眼花
2015-08-10 06:39
天霁
Rank: 2
等 级:论坛游民
帖 子:33
专家分:18
注 册:2015-7-17
收藏
得分:0 
回复 2楼 kenierlee
我想执行的操作)应加在这里吧。

 while((ch=tolower(getchar())!='q')
2015-08-10 06:42
柳逸尘
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:80
专家分:131
注 册:2015-8-10
收藏
得分:0 
47    printf("%10s%10.2lf%10.2lf%10.2lf\n",charge,ARTICHOKE*artichoke,BEET*beet,CARROT*carrot);中charge好像没有定义吧  
54    sum=sum-dicount+freight;中dicount少个s
其实这些自己仔细看看都是可以解决的
2015-08-10 11:01
快速回复:感觉变得挺对的,可编译时提示错误,麻烦翻译一下error和warning,并指 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019914 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved