Description
The purpose of this challenge is to use a DO-WHILE loop while also using constants and accumulators. This challenge implements a menu system and simulates a food ordering scenario.
Requirements
- Declare a double const called MAIN_ENTREE and initialize this to 4.99
- Declare a double const called SIDE_ITEM and initialize this to 0.99
- Declare a double const called DRINK_REG and initialize this to 1.99
- Declare a double const called DRINK_LARGE and initialize this to 2.49
- Within a do-while statement, display to the user a menu of choices where the user can select food items, something similar to below. If you’re feeling creative, you can change the names of the food items
1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Side Item - Flauta (EXTRA CREDIT A) 4 - Regular drink 5 - Large drink S - Start over (EXTRA CREDIT B) C - Check out
- You can use an IF-ELSE-IF or a SWITCH statement to implement the various menu selections.
- The user can order as many counts of each item. This means the user can order 5 burritos, 3 tacos, 1 regular drink and 3 large drinks. You will have to create separate int accumulators to count main entrees, side items and drinks. For example, you might declare an int entrees. Don’t forget that accumulators should be initialized to zero to keep correct count.
- As the user selects an item, update the user with how many items, and which items, have been ordered (see sample interaction below)
- You are only required to write the the code for one main entree, one side item, one regular drink and one large drink. You can create an additional side item menu choice for extra credit. Of course, showing this additional choice in the menu means your code will have to support it.
- For more extra credit, implement option S where the user can start their order over, and re-add items to their order
- The checkout option will tally up the order and calculate how much the user owes. Don’t forget to take into account the multiples of any one item that the user ordered. Disregard taxes. After calculating the total, display to the user the total amount owed and exit the program
- EXTRA CREDIT C – For more practice and more points, after displaying to the user the amount owed, ask the user to enter the amount they are paying while disallowing entry of any amounts less than the amount owed. Use another do-while loop to receive the user’s payment to enforce this restriction. Show to the user the amount of change, if any.
- The sample interaction below shows the minimum expectations without any extra credit features.
DO NOT USE
Functions. WHILE loops. FOR loops
Sample Interaction / Output
1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: 1 You have 1 Main Entree(s), 0 Side(s), 0 Reg Drink(s), 0 Lg Drink(s) 1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: 1 You have 2 Main Entree(s), 0 Side(s), 0 Reg Drink(s), 0 Lg Drink(s) 1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: 2 You have 2 Main Entree(s), 1 Side(s), 0 Reg Drink(s), 0 Lg Drink(s) 1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: 3 You have 2 Main Entree(s), 1 Side(s), 1 Reg Drink(s), 0 Lg Drink(s) 1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: 4 You have 2 Main Entree(s), 1 Side(s), 1 Reg Drink(s), 1 Lg Drink(s) 1 - Main Entree - Burrito 2 - Side Item - Taco 3 - Regular drink 4 - Large drink C - Check out Your choice: C You have 2 Main Entree(s), 1 Side(s), 1 Reg Drink(s), 1 Lg Drink(s) Thank you. Your total is $15.45
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-LOOP0008
Print Requirements