Reference no: EM132208449
Write a program in C(not C+) that simulates a soft drink machine. The program should use a structure that stores the following data:
Drink Name
Drink Cost
Number of Drinks in the Machine
The program should create an array of structures (maximum 20). The elements should be initialized by reading all data from a file called "drinks.txt".
The first line in the data file contains the number of drink records. See sample data below.
Each time a program runs, it should load the data from the file and enter into a loop that displays the list of drinks and their cost on the screen.
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 drinks 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, it should display the total amount of money the machine earned and save all the data back into the input file "drinks.txt".
Next time the program is run, it will load the new data into the array.