| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 764 人关注过本帖
标题:这个程序的逻辑思维怎么理清,请大神帮忙,谢谢。
只看楼主 加入收藏
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
结帖率:71.88%
收藏
已结贴  问题点数:3 回复次数:9 
这个程序的逻辑思维怎么理清,请大神帮忙,谢谢。
要求为一个自行车的网购编写一个c语言程序,具体是:
有四种自行车:Hybrid-MT,Race,Mountain,Touring,分别用H R M T代替,基准价均为1000元。每种自行车的车轮尺寸是22-36,如果尺寸大于22,每多一寸,多收100元。
如果顾客选购 H和T,问他们是否要换舒适的座椅,此项收费为50元。如果选购R、M或T,问顾客是否要升级装备,此项收费是300元。如果购买金额大于2000元,有5%的折扣。税率为13%。
最后还要求显示一天的营业额,总售出自行车数量和价值。
输入:
CROWN BICYCLE CORPORATION – Manager XXX
BIKE MODELS – CUSTOM MADE ORDER, Hybrid-MT,Race,Mountain,Touring,Select (H, R, M or T only): Credit Card (last 6 numbers): 999999
Choose a wheel size between 22 inch and 36 inch:
输出:
CROWN BICYCLE CORPORATION    DATE: yyyy/mm/dd
TOTAL PRICE FOR BIKE:   
DISCOUNT:     (只有总共价值超过2000元才显示)
TAX (13% GST):
TOTAL ORDER:
每日总结报告:
SUMMARY for yyyy/mm/dd
Total number of bikes sold:
Total $ value of bikes sold:
要求:
1、输入输出要使用函数和指针
2、加一个循环,顾客订单结束后询问是否继续下一个订单
搜索更多相关主题的帖子: 自行车 基准价 营业额 价值 
2013-02-25 12:20
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:1 
祝楼主学习进步!

授人以渔,不授人以鱼。
2013-02-25 13:03
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
收藏
得分:0 
谢谢斑竹。我刚写了下面一点,还没完成,请指点:
#include<stdio.h>
/* The purpose of this program is
to perform calculations with functions and pointers.*/
main()
{
int hqty, rqty, mqty, tqty, hwsize, rwsize, mwsize, twsize, hseat, tseat, rupgrade, mupgrade, tupgrade;
double htotal, rtotal, mtotal, ttotal, total price, discount, tax, total order;
char yn='Y';

while (yn=='Y'||yn=='y')
{
printf("\nCROWN BICYCLE CORPORATION – Manager XXX");

get_inputs (&hqty, &rqty, &mqty, &tqty, &hwsize, &rwsize, &mwsize, &twsize, &hseats, &tseats, &rupgrade, &mupgrade, &tupgrade);
htotal=hqty*1000+(hwsize-22)*50+hseat;
rtotal=rqty*1000+(rwsize-22)*50+rupgrade;
mtotal=mqty*1000+(mwsize-22)*50+mupgrade;
ttotal=tqty*1000+(twsize-22)*50+tseat+tupgrade;
total price=htotal+rtotal+mtotal+ttotal;
printf("\nTOTAL PRICE BIKE %10.2lf\n", total price);











printf( "\n\n\nWould you like to take another order? Y/N\n ");
scanf ("%c", &yn);
if(getchar()=='n')
break;
}
}
void get_inputs(int *hqty, *rqty, *mqty, *tqty, *hwsize, *rwsize, *mwsize, *twsize, *hseats, *tseats, *rupgrade, *mupgrade, *tupgrade);
{
char choice;
printf("\nBIKE MODELS – CUSTOM MADE ORDER");
printf("\nH for Hybrid-MT");
printf("\nR for Race");
printf("\n M for Mountain");
printf("\nT for Touring");
printf("\nSelect (H, R, M or T only):");

printf("\n Your Order for H");
scanf("%d", &hqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &hwsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Your choice? yn")
scanf("%c", &choice);
if (choice='Y'||choice='y')
*hseat=50;
else
*hseat=0;

printf("\n Your Order for R");
scanf("%d", &rqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &rwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Your choice? yn")
scanf("%c", &choice);
if (choice='Y'||choice='y')
*rupgrade=300;
else
*rupgrade=0;

printf("\n Your Order for M");
scanf("%d", &mqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &mwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Your choice? yn")
scanf("%c", &choice);
if (choice='Y'||choice='y')
*mupgrade=300;
else
*mupgrade=0;

printf("\n Your Order for t");
scanf("%d", &tqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &twsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Your choice? yn")
scanf("%c", &choice);
if (choice='Y'||choice='y')
*tseat=50;
else
*tseat=0;
printf("\nDo you want the upgraded custom gears? This charge is $300. Your choice? yn")
scanf("%c", &choice);
if (choice='Y'||choice='y')
*tupgrade=300;
else
*tupgrade=0;   
}

2013-02-25 13:39
Susake
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:女儿国的隔壁
等 级:贵宾
威 望:23
帖 子:2288
专家分:6481
注 册:2012-12-14
收藏
得分:1 
你懂的

仰望星空...........不忘初心!
2013-02-25 13:41
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
第二次见类似题目了,出处是哪里?

授人以渔,不授人以鱼。
2013-02-25 13:46
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
收藏
得分:1 
以下是引用TonyDeng在2013-2-25 13:46:33的发言:

第二次见类似题目了,出处是哪里?

可能开学了,学生们开始要做课程设计了...

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2013-02-25 19:47
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
以下是引用peach5460在2013-2-25 19:47:21的发言:


可能开学了,学生们开始要做课程设计了...

第一个就是楼主问的,过年前,我连代码都给了,又问第二次,先前没发觉,后来查一查他的主帖记录才记起。

授人以渔,不授人以鱼。
2013-02-25 20:42
winglesswu
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2013-1-28
收藏
得分:0 
以下是引用TonyDeng在2013-2-25 20:42:11的发言:


第一个就是楼主问的,过年前,我连代码都给了,又问第二次,先前没发觉,后来查一查他的主帖记录才记起。

之前问的是快餐店菜单设计,这次不一样,要求也有所不同。下面是我写的,错误提示总是说scanf("%c", &yn1);不行,请大侠帮忙。
#include<stdio.h>
/* The purpose of this program is
to perform calculations with functions and pointers.*/
main()
{
int hqty, rqty, mqty, tqty, hwsize, rwsize, mwsize, twsize, total_sold;
double hseats, tseats, rupgrade, mupgrade, tupgrade;
double htotal, rtotal, mtotal, ttotal, total, discount, tax, total_order, total_value;
int yyyy, mm, dd;
char yn='Y';

while (yn=='Y'||yn=='y')
{
printf("\nCROWN BICYCLE CORPORATION – Manager");
printf("\nCROWN BICYCLE CORPORATION    DATE: %4d/%02d/%02d", yyyy/mm/dd);

get_inputs(&hqty, &rqty, &mqty, &tqty, &hwsize, &rwsize, &mwsize, &twsize, &hseats, &tseats, &rupgrade, &mupgrade, &tupgrade);
htotal=hqty*1000+(hwsize-22)*50+hseats;
rtotal=rqty*1000+(rwsize-22)*50+rupgrade;
mtotal=mqty*1000+(mwsize-22)*50+mupgrade;
ttotal=tqty*1000+(twsize-22)*50+tseats+tupgrade;
total=htotal+rtotal+mtotal+ttotal;
if (total>2000)
{discount=total*0.05;
tax=(total-discount)*0.13;
total_order=total-discount+tax;
printf("\nTOTAL PRICE FOR BIKE %10.2lf$\n", total);
printf("\nDISCOUNT %10.2lf$", discount);
printf("\nTAX (13% GST) %10.2lf$", tax);
printf("\nTOTAL ORDER %10.2lf$", total_order);
}
else
{
printf("\nTOTAL PRICE FOR BIKE %10.2lf$", total);
printf("\nTAX (13% GST) %10.2lf$", total*0.13 );
printf("\nTOTAL ORDER %10.2lf$", total*1.13);
}
printf( "\nWould you like to take another order? Y/N\n ");
scanf ("%c", &yn);
if(getchar()=='n')
break;
}
total_sold=hqty+rqty+mqty+tqty;
total_value+=total;
printf("\nSUMMARY for %4d/%02d/%02d", yyyy/mm/dd);
printf("\nTotal number of bikes sold: %d", total_sold);
printd("\nTotal value of bikes sold:%10.2lf", total_value);
}

get_inputs(int *hqty, int *rqty, int *mqty, int *tqty, int *hwsize, int *rwsize, int *mwsize, int *twsize,
double *hseats, double *tseats, double *rupgrade, double *mupgrade, double *tupgrade)
{
char yn1, yn2, yn3, yn4, yn5; int credit_card_number;
printf("\nBIKE MODELS – CUSTOM MADE ORDER");
printf("\nH for Hybrid-MT");
printf("\nR for Race");
printf("\nM for Mountain");
printf("\nT for Touring");
printf("\nSelect (H, R, M or T only):");
printf("\nCredit Card (last 6 numbers):%6d ", credit_card_number);

printf("\n Your Order for H:");
scanf("%d", &hqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &hwsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Please enter your choice? yn1")
scanf("%c", &yn1);
if (yn1=='Y'||yn1=='y')
*hseats=50.00;
else
*hseats=0;

printf("\n Your Order for R");
scanf("%d", &rqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &rwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn2")
scanf("%c", &yn2);
if (yn2=='Y'||yn2=='y')
*rupgrade=300.00;
else
*rupgrade=0;


printf("\n Your Order for M");
scanf("%d", &mqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &mwsize);
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn3");
scanf("%c", &yn3);
if (yn3=='Y'||yn3=='y')
*mupgrade=300.00;
else
*mupgrade=0;

printf("\n Your Order for t");
scanf("%d", &tqty);
printf("\nChoose a wheel size between 22 inch and 36 inch");
scanf("%d", &twsize);
printf("\nDo you want the more comfortable seats? This charge is $50. Please enter your choice? yn4");
scanf("%c", &yn4);
if (yn4=='Y'||yn4=='y')
*tseats=50.00;
else
*tseats=0;
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn5");
scanf("%c", yn5);
if (yn5=='Y'||yn5=='y')
*tupgrade=300.00;
else
*tupgrade=0;   
}

2013-02-26 01:47
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
收藏
得分:0 
以下是引用TonyDeng在2013-2-25 20:42:11的发言:


第一个就是楼主问的,过年前,我连代码都给了,又问第二次,先前没发觉,后来查一查他的主帖记录才记起。

呵呵,我一般只做改错不做问答...

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2013-02-26 08:14
liuxia
Rank: 1
等 级:新手上路
帖 子:6
专家分:4
注 册:2013-2-24
收藏
得分:1 
楼主好,我把你的程序下载调试下有多处警告,两个错误不能通过连接。我发现少了两个;,另外,printf有一个你写成了printd.即使连接成功也没有实现预定的功能。好像有死循环。其中你说的“scanf("%c",&yn1)"我在运行这个文件的可执行文件时并没有出错。
“printf("\nCROWN BICYCLE CORPORATION    DATE: %4d/%02d/%02d", yyyy/mm/dd);”这一行当中的yyyy/mm/dd什么时候赋值了?系统默认的赋值又是什么呢?
printd("\nTotal value of bikes sold:%10.2lf", total_value);
printf("\nDo you want the more comfortable seats? This charge is $50. Please enter your choice? yn1")
printf("\nDo you want the upgraded custom gears? This charge is $300. Please enter your choice? yn2")
不好意思,13年前我在学校学习c语言时就一塌糊涂,忘完了!现在网上搜索答案是方便。
2013-02-26 19:33
快速回复:这个程序的逻辑思维怎么理清,请大神帮忙,谢谢。
数据加载中...
 
   



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

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