Computers and Technology
Computers and Technology, 07.05.2021 17:20, dvh

Write a program that simulates a vending machine. The machine holds six snack items labeled them 1 through 6. The program should initially display a menu of items along with their prices: Vending Machine
1. Roasted Almonds --> $1.25
2. Pretzels --> $1.75
3. Chewing Gum --> $0.90
4. Mints --> $0.75
5. Chocolate bar --> $1.50
6. Cookies --> $2.00
The program then should ask the user to enter the item to purchase along with a sum of money. If the money is enough to buy the item, your program should display the name of item purchased along with the change owed to the user (if any). If the money inserted is insufficient, then your program should say so and let the user know how much additional money is needed. Your program must display the money amounts using the dollar sign and two decimal places after the decimal point.
Please note that your program must validate the input given by the user:
The item to purchase an the amount of money are numeric values (e. g. int and float)
If the user enters an invalid choice for an item to purchase, your program should alert the user of the error.
The program should not accept negative values for the sum of money.
Here are a few sample runs:

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 17:30, kenyasutton10
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, BilliePaul95
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
Answers: 1
image
Computers and Technology, 24.06.2019 13:50, Estefaniamarilicolin
What does code do? a creates a text box that says "solid black" b creates a black border of any width c creates a black border 1 pixel wide
Answers: 1
image
Computers and Technology, 24.06.2019 19:50, joejoefofana
How to unblock on chrome book? ?
Answers: 1
Do you know the correct answer?
Write a program that simulates a vending machine. The machine holds six snack items labeled them 1 t...

Questions in other subjects:

Konu
English, 10.12.2020 17:00
Konu
Biology, 10.12.2020 17:00
Konu
Engineering, 10.12.2020 17:00