subject
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:

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
Using a conditional expression, write a statement that increments numusers if updatedirection is 1, otherwise decrements numusers. ex: if numusers is 8 and updatedirection is 1, numusers becomes 9; if updatedirection is 0, numusers becomes 7.
Answers: 1
You know the right answer?
Write a program that simulates a vending machine. The machine holds six snack items labeled them 1 t...
Questions
question
Mathematics, 06.10.2020 14:01
question
Geography, 06.10.2020 14:01
question
Biology, 06.10.2020 14:01
question
Mathematics, 06.10.2020 14:01
question
Social Studies, 06.10.2020 14:01
question
Mathematics, 06.10.2020 14:01
Questions on the website: 13722360