如果有的话,退回所选产品和剩余的更改 [英] Return the selected product and remaining change if any

查看:70
本文介绍了如果有的话,退回所选产品和剩余的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户输入 -  

1>硬币1,5,10,25美分,即一分钱,镍币,一分钱和四分之一

2>允许用户选择产品可乐(25),百事可乐(35),苏打(45)

3>退回所选产品并保留更改(如果有)





我尝试了什么:



我先了解2个问题的答案但我不明白第三个问题



请告知

解决方案

用户输入一些硬币,这是混合面额。他选择了一个有价格的产品。

你的任务是检查他输入的产品总价格,如果他已经支付了足够的价格从输入总数中减去价格,并算出最小数量返回的硬币。

因此,如果他进入两个季度,那就是50c。他选择了百事可乐,所以你欠他15c的变化。最小数量的硬币是硬币和镍币。



现在就知道了吗?


引用:

我理解前2个问题的答案,但我不明白第3个问题



怎么可能?从来没有看过自动售货机?

当你在机器上买东西时,你明白机器是否会给你改变多少?

即问题3。 / BLOCKQUOTE>

User input-

1>Coins of 1,5,10,25 Cents, i.e., penny, nickel, dime, and a quarter

2>Allow a user to select products Coke(25), Pepsi(35), Soda(45)

3>Return the selected product and remaining change if any



What I have tried:

I understood first 2 question answer but i don't understand 3rd Questioned

Kindly Inform

解决方案

The user inputs a number of coins, which are mixed denominations. He selects a product which has a price.
You task is to check the total he entered against the product price and if he has paid enough subtract the price from the input total, and work out the minimum number of coins to return.
So if he enters two quarters, that's 50c. He selects a Pepsi, so you owe him 15c change. The smallest number of coins is a dime and a nickel.

Get the idea now?


Quote:

I understood first 2 question answer but i don't understand 3rd Questioned


How is it possible ? Never saw a vending machine ?
When you buy something in a machine, do you understand if the machine will give you change and how much ?
that is question 3.


这篇关于如果有的话,退回所选产品和剩余的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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