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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started