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

\"I DO NOT NEED THE PROGRAM WRITTEN JUST AN ALGORITHM AND PSEUDOCODE!\" write a

ID: 3632351 • Letter: #

Question

"I DO NOT NEED THE PROGRAM WRITTEN JUST AN ALGORITHM AND PSEUDOCODE!"

write a program that simulates a soft drink machine. the program should use a structure that stores the following data:

drink name (as a character, “c” for cola, “r” for rootbeer, “l” for lemon-lime, ‘g” for grape,
“s” for strawberry)
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 number in machine
cola .75 5
root beer .75 1
lemon-lime .75 0
grape soda .80 14
strawberry soda .80 7

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 oney that is to be inserted into the drink 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 been 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 that the machine earned.
input validation: when the user enters an amount of money, do not accept negative input or values greater than $1.00. if the user has not input enough money to purchase the selected drink, a message should be generated telling the user that he did not input enough money.


Explanation / Answer

STEP1: start
STEP2:cout<< "display the MENU
(“c” for cola, “r” for rootbeer, “l” for lemon-lime, ‘g” for grape,
“s” for strawberry)"
STEP3:struct list
{
cola .75 5
root beer .75 1
lemon-lime .75 0
grape soda .80 14
strawberry soda .80 7
}
STEP4: cin >>" enter the CHOICE"
STEP5: switch(ch)
{
case 'c':
cout<< "the drink you ordered is cola and the cost is 75.5";
end;
case 'r':
cout<< " the drink you ordered is root beer and the cost is 75.1";
end;
case 'g':
cout<< " the drink you ordered is gape soda and the cost is 80.14";
end;
case 's':
cout<< " the drink you ordered is strawberry soda and the cost is 80.7";
end;
end switch;
}

STEP6:stop