Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with problem 8. It\'s C programming. Write a program that will simul

ID: 3842021 • Letter: I

Question

I need help with problem 8. It's C programming.

Write a program that will simulate a soft drink machine that dispenses four types of soft drinks. The program will accept character input only. The symbols 'C' 'O', 'L', and 'S' will stand for the drinks (Cola, Orange, Lemon, and Spritzer). The symbols 'N', 'D', and 'Q' will stand for the coins nickel, dime, and quarter). No other coins will be accepted. The character 'R' when read as input will stand for the coin return. Any time that 'R' is input, all money should be returned to the user. The program will output messages that simulate the output from the soft drink machine. For example, "cola dispensed, " "30 cents returned", "Sorry, out of Spritzer, " or " Your change is 10 cents." In addition to accepting input of the money and drink selections, and displaying messages to the user, the program will internally keep track of the amount of change, and the inventory each drink. A sample run follows. Enter 65 cents for a drink > Q 25 cents received > D 35 cents received > D 45 cents received > D 70 cents received Make your drink selection now > o Orange drink dispensed 5 cents in change given Enter 65 cents for a drink > Q 25 cents received >Q 50 cents received > C Sorry, insufficient funds entered Please enter additional 15 cents > R 50 cents returned Enter 65 cents for a drink > Write your program in a modular structured style with the different modules in separate source files. Plan the communication between the different parts of the program. Minimize your use of global variables.

Explanation / Answer

#include #include #include #include #include using namespace std; struct Machine { string name; double cost; int num; }; void init(Machine []); int menu(Machine[]); void payment(double); int main() { Machine drink[5]; int choice; double made=0; init(drink); choice=menu(drink); while(choice!=5) { payment(drink[choice].cost); made+=drink[choice].cost; drink[choice].num--; choice=menu(drink); } cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote