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, 23.06.2019 10:00
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
question
Computers and Technology, 24.06.2019 20:00
Individuals suffering from technology overload feel distressed when deprived of computers and mobile devices.true/fasle
Answers: 2
question
Computers and Technology, 25.06.2019 04:10
8. create an abstract student class for parker university. the class contains fields for student id number, last name, and annual tuition. include a constructor that requires parameters for the id number and name. include get and set methods for each field; the settuition() method is abstract. create three student subclasses named undergraduatestudent, graduatestudent, and studentatlarge, each with a unique settuition() method. tuition for an undergraduatestudent is $4,000 per semester, tuition for a graduatestudent is $6,000 per semester, and tuition for a studentatlarge is $2,000 per semester. write an application that creates an array of at least six objects to demonstrate how the methods work for objects for each student type. save the files as student.java, undergraduatestudent.java, graduatestudent.java, studentatlarge.java, and studentdemo.java.
Answers: 1
question
Computers and Technology, 25.06.2019 09:30
Which resource produces the cleanest energy? -coal -gasoline -oil -wind
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
History, 17.12.2020 01:10
question
Advanced Placement (AP), 17.12.2020 01:10
question
Chemistry, 17.12.2020 01:10
question
Advanced Placement (AP), 17.12.2020 01:10
Questions on the website: 13722359