Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++- Homework 9 (Drink Machine Simulator) Write a program that simulates a soft drink machine The program should use a structure that stores the following
C++- Homework 9 (Drink Machine Simulator) Write a program that simulates a soft drink machine The program should use a structure that stores the following data Drink nam Drink Cost Number of Drinks in Machine The program should create an array of five structures. The elements should be initialized with the following data Drink Name Cost 0.85 0.75 0.90 0.80 0.80 Number in Machine 20 20 20 20 20 Cola Root Beer Lemon-Lime Grape Soda Cream Soda Each time the program runs, it should enter a loop that performs the following steps: A list of drinks is displayed on the screen. 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 machine. The program should display the amount of change that would be returned and subtract one from the number of that drink left in the machine. If the user selects a drink that has sold out, a message should be displayed. The loop then repeats. When the user chooses to quit the program is should display the total amount of money the machine entered and which drink is sold out. Input Validation: When the user enters an amount of money, do not accept a negative values, or values greater than $1.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