C# Drink Vending Machine (Objects, Classes, Switch Statements, User Input)

Share it with your friends Like

Thanks! Share it with your friends!

Close

Purpose:
The vending machine program will allow the user to make a selection from a simulated drink machine. The user will simulate inserting coins. When enough money has been entered, the user will make his selection of drink.

Program Procedures:
From a console app, the user will be prompted and then enter in a number on the screen, then press the enter key to simulate money being entered A drink selection is made when a sufficient amount has been collected. A list of available drinks should be displayed to the user with a keyboard key highlighted to represent the user selecting a particular drink. Once the user has made his selection, a message should appear, thanking the user for the selection (including the name of the selection) and the amount of change (if any) to be returned to the user.

Algorithms and Conditions:
1. The end user should be prompted to keep entering money until enough has been entered.
2. Part of the prompt should include what is considered to be a valid entry (.e.e 5 for a nickel, 10 for a dime etc). If end user enters an invalid amount, the user should be told and allowed to retry until a valid entry is made.
3. After each coin is inserted, let the user know how much he has put in so fat in addition to the original prompt. The price of all of the drinks is $1.50.
4. After enough money is entered, the drink machine should display a minimum of 3 selections. The user will type the key of the corresponding drink selection.
5. After a selection has been made, a message should tell the user what he has selected and return any change to the user by displaying how much change the user should receive.

Notes and Restrictions:
1. The only valid entries for cons are 5, 10, 25, 100
2. Two classes are to be used. The DrinkMachine class will have 1 read only property for amount of money entered so far. It will have at least 3 methods:
a) DepositCoin() – accepts 1 parameter, validates entry, prints error message if entry is incorrect, otherwise adds to running total for correct entry
b) DisplayDrinkSelections() – after a proper amount of money is entered, prints the drink selection screen to the user.
c) MakeDrinkSelection() – accepts 1 parameter, displays to the user a thank you message and the selection that was made.

Comments:
1. The number of drink items stated above is a minimum (3 drinks). You may use more of you choose.
2. All variables, objects, classes, properties and methods must have meaningful names and use proper notation.

Sample Input/Output:
Please enter a coin or a dollar bill (5, 10, 25, 100)

(assume $1.50 or 150 cents has been entered)

*****************
* C – Coke *
* P – Pepsi *
* D – Diet Coke *
*****************

(assume D was pressed)
Thank you for choosing a Diet Coke.

Comments

Write a comment

*