Question
//please use c++ In this program you will practice aggregation of classes - this is a HAS A relationship. Create a Drink/Item class and a
//please use c++
In this program you will practice aggregation of classes - this is a "HAS A" relationship.
Create a Drink/Item class and a Vending machine class.
The Drink/Item class will hold names of items, prices of items, and quantity in the machine.
The vending machine attributes will be an array of Drink/Item objects, total amount of drinks sold, and name of machine.
Each time the program runs, it should enter a loop that performs the following steps.
1) Display the list of drinks available and their prices
2) The user should be allowed to either quit the program or pick a drink.
If the user selects a drink, he or she will next enter the amount of money that is to be inserted into the drink machine.
3)The program should display the amount of change that would be returned and subtract one from the number of drinks of that type left in the machine.
If the user selects a drink that is sold out, a message should be displayed.
4) The loop then repeats.
5) When the user chooses to quit the program it should display the total amount of money the machine has earned.
Input validation: When the user enters an amount of money, do not accept negative values or values greater than $5.00
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