Question: using c# 5.0 Create a program that allows the user to fill a vending machine and purchase items from it. The program should use a

using c# 5.0

Create a program that allows the user to fill a vending machine and purchase items from it.

The program should use a Stack to implement last-in-first-out (LIFO) behavior. The vending machine always vends the item that was most recently added to it.

The user should be able to stock an item in the machine or buy an item from the machine.

The program should inform the user if the machine is empty when they attempt a purchase.

Sample Program Run

After your program runs, the console should look similar to the following example. The exact output will vary depending on what the user inputs.

Vending Machine Do you want to (A - Add Item, B - Buy Item, E - End): A Coke Do you want to (A - Add Item, B - Buy Item, E - End): A Coke Do you want to (A - Add Item, B - Buy Item, E - End): A Sprite Do you want to (A - Add Item, B - Buy Item, E - End): B You bought a Sprite Do you want to (A - Add Item, B - Buy Item, E - End): B You bought a Coke  Do you want to (A - Add Item, B - Buy Item, E - End): A Dr Pepper Do you want to (A - Add Item, B - Buy Item, E - End): B You bought a Dr Pepper Do you want to (A - Add Item, B - Buy Item, E - End): B You bought a Coke  Do you want to (A - Add Item, B - Buy Item, E - End): B There are no items in the vending machine Do you want to (A - Add Item, B - Buy Item, E - End): E Thank you for using the vending machine!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!