-->
当前位置:首页 > 题库

PROGRAMMING:vending machine

Luz5年前 (2021-05-10)题库435
In the simple vending machine as shown in the figure, there are 10 kinds of goods on shelves 1 and 2, which are numbered in sequence as 1-10, marked with price and name. One number corresponds to one operable button for selecting goods. If the goods on the shelf are bought by the user, the goods will be automatically taken out from the locker and sent to the shelf to ensure that there will be goods on the shelf. Users can input more money at a time, and can choose a variety of goods. Vending machines can output goods at one time and change.
![ 1.jpg](~/e2bba5b3-dd4a-44fe-8aaf-51a520f3c2cf.jpg)
The operation method for users to purchase goods is as follows:
(1) Put in coins from the "coin entrance" and put in multiple coins or notes in turn. Coins can support 1 yuan (banknote, coin), 2 yuan (banknote), 5 yuan (banknote) and 10 yuan (banknote). When the coins are put in, the controller will first check the coins, identify the currency value, and count the total currency value, which will be displayed in the controller display screen to prompt the user to confirm that the coins are put in;
(2) When the user confirms that the coin has been put in, he can select the commodity. Just press the number button on the outside of the corresponding commodity with his finger. For each product selected, the vending machine controller will judge whether the coins are enough to buy. If the coins are enough, the vending machine controller will automatically count the items according to the number, calculate the required value of coins, and prompt the balance. If there is not enough money, the controller will prompt "insufficient money". The user can cancel the purchase and will return all the coins to the user.
###Input format:
First, input the coin value sequence, with - 1 as the end, and then successively input multiple purchase commodity numbers, with - 1 as the end.
###Output format:
Output the total amount of money and change, as well as the name and quantity of goods purchased.
###Input example:
```in
1 1 2 2 5 5 10 10 -1
1 2 3 5 1 6 9 10 -1
```
###Output example:
```out
T otal:36yuan , change:19yuan
Table- water:2; Table- water:1; Table- water:1; M ilk:1; B eer:1; Oolong-Tea:1; Green-Tea:1;
```







answer:If there is no answer, please comment