Jose R. answered 07/16/24
Prompt for Beverage Quantity:
- Use
cin
to ask the user to enter the quantity of beverages they want to order. - Store this quantity in an integer variable.
Initialize Total Price:
- Declare a variable to store the total price, initialized to 0.0.
Loop Through Each Beverage Order:
- Use a
for
loop to iterate from 0 to the quantity of beverages minus one. - Inside the loop, perform the following steps for each beverage:
Display Beverage Menu:
- Print a menu with the beverage options and their prices
Get User's Beverage Choice:
- Prompt the user to enter their choice of beverage (1, 2, or 3).
- Store the user's choice in an integer variable.
Get User's Milk Preference:
- Prompt the user to enter whether they want additional milk (Y or N).
- Store the user's preference in a character variable.
Determine the Price for the Selected Beverage:
- Use a
switch
statement (orif-else
structure) to set the price based on the user's beverage choice. - If the choice is 1 (Espresso), set the price to 1.50.
- If the choice is 2 (Cappuccino), set the price to 2.50.
- If the choice is 3 (Latte), set the price to 2.00.
Add Extra Milk Price if Needed:
- If the user chose 'Y' for additional milk, add 0.50 to the price of the beverage.
Update the Total Price:
- Add the price of the current beverage (including extra milk if applicable) to the total price variable.
After the Loop, Display the Total Amount:
- Once all beverages have been processed, print the total amount to be paid using
cout
.