Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 of 2 rogramming Assignment #7 Simulate a Vending Machine CS 1428 302, Spring 2018 InstructorSeaman Due: in class Tuesday, 4/24/2018 (upload electronic copy by

image text in transcribed
1 of 2 rogramming Assignment #7 Simulate a Vending Machine CS 1428 302, Spring 2018 InstructorSeaman Due: in class Tuesday, 4/24/2018 (upload electronic copy by 9.00am) write a program that simulates a soft drink machine. The program should use a structure that stores the following data: Drink Name Drink Cost Number of units currently in the machine The program should create an array of five sbructures. The elements should be initialized with the following data: Coke (can Coke (bote Mountain Dew (can) 1.25 0.75 1.25 2.00 Full Throtle Each time the program runs, it should enter a loop that performs the following steps A ist of drinks is dsplayed on the soreen. The user should be allowed to ether quit the program or pick a drink. If the user selects a drink (that has not sold out), the program should display the cost of the drink and subtract one from the number of units of that drink left in the machine. If the user selects drink that has sold out, amessage should be displayed. The loop then repeats. When the user chooses so quit the program it should display the number of unts of each dink madine and the total amount of money the machine earned Sample output is on the class website. Your program must compile and run, otherwise you will receive a score of C Use named constants for the number of drinks and the initial quancty The drinks array must be processed using loops Top Down Design: your program must perform these four tasks (write a separate function for each one): 1 Show the drink cholces and get the user's choice. 2. Process the user's choice. 3. Output the number of units of each drink currently in the machine 4, Calcalabe the earnings (return the value, no output) Since there is only one amay in the program you do not need to pass the size as a . parameter to the functions (but you can i you want to). I recommend using integers for the drink choices Qike a menu). However: De not or if/else to process the drink the choice is of the drinks (1-5) you should process them using the same code Validate the drink doce nput from the user Creener not between 1 and 6). Style: See the Style Guidelines document on the course website. Especialy pay attention to the comments required for functions. Include the full comments required for your functions this timet The grader will deduct points if your program violates the style guidelines Make your program output look nce

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago