Your program should work as follows:
Choosing variable type Throughout your program, you should store the prices, the amount due, and the balance in terms of cents (to avoid rounding errors when working with double or float).
Writing functions You are required to define several functions in this program:
void ReadMenu (string drinksName[], int drinkPrice[], int & size)
void DisplayMenu (string drinksName[], int drinkPrice[], int size)
/* Keep prompting user to enter a coin until the total amount entered is no less than the totalDueInCents, or until the user cancels In the former case, the function returns true, and set totalEntered to the total value of coins entered; In the latter case, the function return false */ bool TakeCoins (int totalDueInCents, int & totalEntered) { }
Example output
$a.out YouthDrink Corp. Vending Machine Loading menus.... Enter number of drinks:4 Enter 4 drink names:coke orange_juice root_bear water Enter their prices: 250 260 320 180 Starting the machine.... Enter a command: Start (a new order) or Shutdown (the machine):Start We offer the following drinks: *********************** 1. coke ($2.50) 2. orange_juice ($2.60) 3. root_bear ($3.20) 4. water ($1.80) *********************** Enter the number for the drinks, or enter -1 to quit: 1 You ordered: coke Total due $2.50. Enter coins (D for dollar, Q for quarter, M for dime, N for nickel, C to quit): D $1.00 entered. Enter coins (D for dollar, Q for quarter, M for dime, N for nickel, C to quit): D $2.00 entered. Enter coins (D for dollar, Q for quarter, M for dime, N for nickel, C to quit): D $3.00 entered. Giving change: $0.50 Enjoy your drink. Enter a command: Start (a new order) or Shutdown (the machine):Start We offer the following drinks: *********************** 1. coke ($2.50) 2. orange juice ($2.60) 3. root bear ($3.20) 4. water ($1.80) *********************** Enter the number for the drinks, or enter -1 to quit: -1 Order cancelled. Enter a command: Start (a new order) or Shutdown (the machine):Shutdown Vending machine shutting down!
How to submit Please submit your program (named finallab.cpp) to the following site by Dec 14, Wed, midngiht:
Please email the instructor if you encounter any problems with the testcases.