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

PROGRAMMING:Inquire the price of the goods in the vending machine

Luz5年前 (2021-05-10)题库432
Given four commodities, namely crisps, popcorn, chocolate and cola, the unit price is 3.0 yuan / kg, 2.5 yuan / kg, 4.0 yuan / kg and 3.5 yuan / share respectively.
First, the following menu is displayed on the screen:
```
[1] crisps
[2] popcorn
[3] chocolate
[4] cola
[0] exit
```
The user can enter the number 1 ~ 4 to query the unit price of the corresponding food. When the number of continuous queries exceeds 5, the program shall automatically exit the query; Less than 5 times and the user enters 0 to exit; Enter another number to display the price as 0.
###Input format:
Enter a number of numbers in a row that give the user continuous input.
###Output format:
First, the menu is displayed on the screen. Then, corresponding to each input of the user, the query result is output in a row according to the format of "price = price", where the price retains one decimal place. When the user queries for more than 5 times in a row, or actively enters 0, the program ends and "thanks" is displayed.
###Input sample 1:
```in
1 7 0 2
```
###Output sample 1:
```out
[1] crisps
[2] popcorn
[3] chocolate
[4] cola
[0] exit
price = 3.0
price = 0.0
Thanks
```
###Input sample 2:
```in
1 2 3 3 4 4 5 6 7 8
```
###Output sample 2:
```out
[1] crisps
[2] popcorn
[3] chocolate
[4] cola
[0] exit
price = 3.0
price = 2.5
price = 4.0
price = 4.0
price = 3.5
Thanks
```






answer:If there is no answer, please comment