您好。我正在上一个C ++程序课,不明白我在做什么,我的导师没有帮助,所以这就是我在这里的原因。我似乎无法掌握任何概念,我不知道为什么。有人可以帮我这个: 蓝鸟航空有从凤凰城到亚利桑那州其他六个城市的航班。 城市的编号是1到6.这里显示了每个城市的往返机票的价格。 City 1 2 3 4 5 6 价格56.79 105.69 93.49 155.99 87.49 73.99 编写一个程序,计算客户订购的门票总价。 该程序应提示用户输入目的地城市的号码和 所需的门票数量。如果用户输入无效的城市号码,pro- 克应显示错误信息并终止。该程序应显示 门票订单的总价。使用数组存储门票价格表。 任何帮助将不胜感激。 谢谢, 玛丽:)
解决方案首先你需要理解手头的任务。
- 启动程序在命令提示符下(这不是一个显示图形用户界面的程序,只是从命令提示符中询问某些用户输入),例如请输入城市代码范围1到6:_
- 输入1到6之间的数字(代表其中一个可用城市),例如请输入1到6范围内的城市代码:3 请输入1到20范围内的门票数量:_
- 输入介于1和20之间的数字(表示要购买的门票数量)
- 该程序计算所选城市门票的总价,例如 double total = getTicketPrice(cityId)* numberOfTickets
- 程序显示结果,例如请输入1到6之间的城市代码:3 请输入1至20范围内的门票数量:2 '城市2张门票的总价3'是2 x 93.49 = 186.98
- 在命令提示符下启动程序,例如请输入1到6范围内的城市代码:_
- 输入超出范围的数字,例如0(或-3,或7,或100)请输入1到6:0范围内的城市代码
- 程序报告错误并终止,例如请输入1到6范围内的城市代码:0 错误:您输入的城市代码超出范围。请输入1到6之间的代码。
玩得开心! 干杯 Andi
引用:
我可以似乎没有掌握任何概念我不知道为什么。
那我们怎么知道? 这里我们回答成员在编程时遇到的具体问题。 如果您在编码时遇到任何困难,请随时回到这里,并针对描述该场景的特定问题提出另一个问题。 各位会员很乐意为您提供帮助。 :)
Hi. I am taking a C++ program class and do not understand what I am doing and my instructor is no help so that is why I am here. I just can't seem to grasp any concepts and I don't know why. Can someone please help me with this: Bluebird Airlines has flights from Phoenix to six other cities in Arizona. The cities are referred to by number,1 to 6.The price for a round-trip ticket to each of the cities is shown here. City 1 2 3 4 5 6 Price 56.79 105.69 93.49 155.99 87.49 73.99 Write a program that computes the total price of tickets that a customer orders. The program should prompt the user for the number of the destination city and the number of tickets desired.If the user enters an invalid city number,the pro- gram should display an error message and terminate.The program should display the total price of the ticket order.Use an array to store the ticket price table. Any help would be greatly appreciated. Thanks, Mary :)
解决方案 First of all you need to understand the task at hand.- start the program on the command prompt (this is not a program that shows a graphical user interface but only asks some user input from the command prompt), e.g.Please enter a city code in the range 1 to 6: _
- enter a number between 1 and 6 (representing one of the available cities), e.g.Please enter a city code in the range 1 to 6: 3 Please enter the number of tickets in the range 1 to 20: _
- enter a number between 1 and say 20 (representing the number of tickets to buy)
- the program calculates the total price of the tickets to the selected city, e.g. double total = getTicketPrice(cityId) * numberOfTickets
- the program displays the result, e.g.Please enter a city code in the range 1 to 6: 3
Please enter the number of tickets in the range 1 to 20: 2
The total price of the 2 tickets to 'city 3' is 2 x 93.49 = 186.98
- start the program on the command prompt, e.g.Please enter a city code in the range 1 to 6: _
- enter a number that is out of range, e.g. 0 (or -3, or 7, or 100)Please enter a city code in the range 1 to 6: 0
- the program reports an error and terminates, e.g. Please enter a city code in the range 1 to 6: 0
Error: You entered a city code that is out of range. Please enter a code in the range 1 to 6.
Have fun! Cheers Andi
Quote:I just can't seem to grasp any concepts and I don't know why.
Then how could we know? Here we answer specific questions which members face during programming. If you face any difficulty while coding, feel free to come back here and ask another question with specific issue describing the scenario. Members will be happy to help you then. :)
更多推荐
我该怎么做这个程序?
发布评论