Anonymous answered this71 answers
Answer: HERE IS THE CODE IN C++ :
HOPE THIS WILL HELP YOU

PLEASE LIKE

Was this answer helpful?
0
NOTE THIS ANSWER IS WRONG SO DONT COPY FROM ANYWARE
int mainQ/main couts DrinkData drinkList[5]; drinklist[0] name "Coke (can)"; drinkl ist[0] price 0.75; drinklist[0].quantityLeft COUNTI drinkList[1] name="Coke (bottle)"; drinkt ist[1] price 1.25; drinklist[1] quantityLeft-COUNTI; drinklist[2] name="Sprite (bottle)"; drinki ist[2] price-125; drinkt ist(2) quantityLeft-COUNTI: drinkList[3] name="Water"; drinkt ist[3] price-1.25; drinktist[3) quantityLeft-COUNTE drinkd.ist(4) name="Red Bull, drinklist/4) price-2.00; drinki ist(4) quantityLeft-COUNTI showChoices(drinkt ist)://call function showChoices calculateEamningsidrinktist)call function calculateEarnings T return 0 code is in C++1 am getting the following errors Program generated too much output Output restricted to 50000 characters. Check program for any unterminated loops baktedindofstream& main cpp 69:36: error:void value not ignored as it ought to be doub O
void showChoices(DrinkData drinkList[5])//function showChoices cout<<"Vending Machine options": cout<<"\n[0] Coke (can)...$0.75"; cout<<"\n[1] Coke (bottle)...$1.25"; cout<<"\n[2] Sprite (bottle)...$1.25"; cout<<"\n[3] Water...$1.25"; cout<<"\n[4] Red Bull...$2.00"; int choice; dol cout<<"\nEnter your choice (-1 to quit):"< cin>>choice; if(choice!=-1){ if(drinklist[choice].quantityLeft==0) cout<<"Sold out!"; else{ cout<<"The price is: $*< drinkList[choice].quantityLeft-; 1 1 while(choice!=-1); 1 void calculate Earnings(DrinkData drinkList[5]//function calculateEarnings double sum=0; for(int i=0;i<5;i++){ sum-drinkList price*(COUNT1-drinkList.quantityLeft): } cout<<"Amount earned by machine: $"<) int main(//main coute DrinkData drinkList[5]: drinklist[0] name="Coke (can)" drinkList(01.price=075
Vending Machine options: [0] Coke (can)...$0.75 [1] Coke (bottle)...$1.25 [2] Sprite (bottle)...$1.25 [3] Water...$1.25 [4] Red Bull...$2.00 Enter your choice (-1 to quit): 0 The price is: $0.75 Enter your choice (-1 to quit): 4 The price is: $2.00 Enter your choice (-1 to quit): 0 The price is: $0.75 Enter your choice (-1 to quit): 1 The price is: $1.25 Enter your choice (-1 to quit): 0 The price is: $0.75 Enter your choice (-1 to quit): 0 Sold out! Enter your choice (-1 to quit): 2 The price is: $1.25 Enter your choice (-1 to quit): -1 Amount earned by machine: $6.75 #include #include using namespace std; const int COUNT1=3; const int NumOfDrinks=5; struct DrinkData//struct DrinkData string name:
The drink's name The drink's price in dollars and cents. The number of units of that drink left in the machine (the quantityLeft). You must use the bolded identifiers above when naming your struct and its members. Also use double for all values representing money. The program should keep an array of 5 of these structures. When the program runs, it should initialize the array using the following data (COUNT is a named constant, set it to 3): ("Coke (can)", 0.75, COUNT), ("Coke (bottle)", 1.25, COUNT), ("Sprite (bottle)",125, COUNT), ("Water", 1.25, COUNT), ("Red Bull", 200, COUNT) It then shows a table that displays the list of drinks and their prices, numbered 0 to 4. The program asks the user to enter a selection (-1 to quit). If that drink is not sold out, it displays the price and updates the quantity (otherwise it displays a "sold out" message). After the user enters -1, the program calculates and displays the amount of money earned by the machine. See the sample execution below. Your program must include the following two functions: showChoices to display the drink choices and calculate Earnings to calculate and return the machine's earnings. These functions should take an array of Drinks as an argument. Do not include a parameter for the size. Do not use a running total in main to calculate the earnings. Your program must have two global named constants, one for the number of drinks (5), and one (called COUNT above) for the initial quantity of each drink in the machine (3).