java,算法问题 [英] java, algorithm problem

查看:53
本文介绍了java,算法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好伙计们我​​在java和算法中有一些问题

他们中的大多数我没有遇到问题,但是我有两个难以理解他们可以帮助我吧请考虑它紧急 。

问题是:


Q1.DVD销售和运输算法设计:


你要设计一个用于计算多个DVD的客户订单总成本的算法。总数由DVD的组件和运费组成。费用确定如下:

? DVD每张售价19.95美元

?对于所选择的每4张DVD,第5张DVD是免费的(因此,如果客户选择了
10张DVD,他们支付8并获得2张免费)

?运费根据下表计算:

DVD数量每件商品的运费

1 4张DVD:每张DVD 2.00美元

5到8张DVD:每张DVD 1.75美元

9到13张DVD:每张DVD 1.50美元

14或以上:每张DVD 1.00美元


设计一种算法,提示操作员购买的DVD数量为
。然后根据上面的详细信息计算DVD费用以及运费

。然后应显示最终总数。


Q3。火车票算法设计:


您要设计一种运行火车售票机的算法。机器

允许用户通过一系列

菜单选择他们想要的机票。根据选择,机器计算总数,接受用户的钱,计算任何欠款,然后允许用户收集他们的票和更改。


以下是系列用户必须选择的菜单:


菜单1:年龄组

A.儿童

B.成人

C.特许经营


菜单2:区域选择

A.区域1

B.区域2

C.区域1和2

D.取消


菜单3:持续时间

A. 2小时

B.全天

C.取消


用户将获得价格,然后输入金额将

提交到系统中,系统将计算任何欠款。

特定机票的价格取决于选择。以下描述

详细说明价格:


?孩子:永远免费

?成人:仅在一个区域内获得2小时罚单2.00美元。加上1.00美元去旅行
区域。加上2.00美元全天旅行。

?优惠:仅在一个区域内获得2小时罚单1.50美元。加上0.50美元旅行

两个区域。全天旅行加$ 1.00


请注意,用户可以在此过程中取消。此选项将它们带回到开头。您的程序还应处理来自用户的任何无效输入,并显示以下消息:?输入无效?请重新输入选择?


非常感谢你们因为我无法解决这两个问题,但除了这两个问题之外其他问题都很容易。

thanx

hello guys i have a bunsh of questions in java and algorithm
most of them i didnt have a problem in them but two i had a diffculty in them could u help me in them please coz its urgent .
the questions are:

Q1.DVD Sales and Shipping Algorithm Design:

You are to design an algorithm to calculate the total cost of a customer order for a number of DVDs. The total is comprised of a component for the DVDs, and also a shipping cost. The costs are determined as follows:
? DVDs cost $19.95 each
? For every 4 DVDs chosen, the 5th one is free (so if the customer chooses
10 DVDs, they pay for 8 and get 2 free)
? The shipping cost is based on the following table:

Number of DVDs : Cost per item to Ship
1 to 4 DVDs : $2.00 per DVD
5 to 8 DVDs : $1.75 per DVD
9 to 13 DVDs : $1.50 per DVD
14 or more : $1.00 per DVD


Design an algorithm that will prompt an operator for the number of DVDs being
purchased. It is then to calculate the DVD charge as well as the shipping cost
based on the details above. The final total should then be displayed.


Q3. Train Ticket Algorithm Design:

You are to design an algorithm to run a train ticketing machine. The machine
operates by allowing a user to choose their desired ticket through a series of
menus. Based on the selections, the machine calculates a total, accepts money from the user, calculates any change owing and then allows the user to collect their ticket and change.

Below is the series of menus the user must choose from:

Menu 1: Age Group
A. Child
B. Adult
C. Concession

Menu 2: Zone Choice
A. Zone 1
B. Zone 2
C. Zone 1 and 2
D. Cancel

Menu 3: Duration
A. 2 hours
B. All Day
C. Cancel

The user will then be given the price and should then enter the amount being
tendered into the system, where the system will then calculate any change owing.
The price of a particular ticket depends on the selections. The description below
details the pricing:

? Child: Always free
? Adult: $2.00 for a 2 hour ticket in only one zone. Add $1.00 to travel both
zones. Add $2.00 to travel all day.
? Concession: $1.50 for a 2 hour ticket in only one zone. Add $0.50 to travel
both zones. Add $1.00 to travel all day

Note that the user can cancel during the process. This option takes them back to the beginning. Your program should also handle any invalid input from the user with the following message: ?Invalid input ? please re-enter choice?

thank you guys very much becouse i couldnt solve these two questions, but the rest of the questions easy except these two.
thanx

推荐答案

19.95每个
?对于所选择的每4张DVD,第5张DVD是免费的(因此,如果客户选择了
10张DVD,他们支付8并获得2张免费)

?运费根据下表计算:

DVD数量每件商品的运费

1到4张DVD:
19.95 each
? For every 4 DVDs chosen, the 5th one is free (so if the customer chooses
10 DVDs, they pay for 8 and get 2 free)
? The shipping cost is based on the following table:

Number of DVDs : Cost per item to Ship
1 to 4 DVDs :


2.00每张DVD

5到8张DVD:
2.00 per DVD
5 to 8 DVDs :


每张DVD 1.75美元

9到13张DVD:
1.75 per DVD
9 to 13 DVDs :


这篇关于java,算法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆