Question


Write a program that displays this to the user. Hot Beverage Menu A: Coffee $1.00, B: Tea $ 0.75, C: Hot Chocolate $1.25, D: Cappuccino S2.50, E: Exit Menu Prompt the user to make a selection. Determine which item the user entered. Use a do-while loop that keeps repeating till the user selects E from the Menu. If the user has selected a valid beverage, prompt the user for how many cups they would like, and print out how much they owe. Submission Run 2 Teas, 4 Hot Chocolates, 10 Coffees, l Cappuccino, ‘F, ‘E.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

P:ledxc+balagurusamy\menu.cpp - [Executing] - Dev-C++ 5.11 Eile Edit Search View Project Execute Iools AStyle Window Help Pr menu.cpPP 并includeくiostream» #includec string» #include<conio.h> using namespace std; Pledxic++ balagurusamyl menu.exe ot Beverage Henu: : Coffee $1.60 B:Tea $0.75 C: Hot Chocolate $1.25 D: Cappuccino $2.50 6int main Exit Henu nter your choice: B otal Bill: $1.5 declare a char to store the user choice char user_choicej 10 How nany cups of Tea vould you like? 2 12 13 // display the menu to the user cout くく Hot Beverage Menu : \n くく endl; cout <<A: Coffee $1.00 << endlj cout << B: Tea $0.75 << endlj cout くく C: Hot Chocolate $1.25 << endl; cout くく D: Cappuccino $2.50 くくendl; cout <<E: Exit Menu In << endl; ot Beverage Henu: 15 16 17 : Coffee $1.60 B:Tea $0.75 C: Hot Chocolate $1.25 D: Cappuccino $2.50 Exit Henu 19 21 23 25 27 nter your choice: C // get the user choice cout くく Enter your choice: ; cin > user_choicej How nany cups of Hot Chocoloate would you like? 4 Total Bill: $5 // declare an int to store the number of cups user want and a double to store the total bill int nun cupsj double total; 29 30 31 32 // check the user choice and ask for number of cups and then calculate the total bill based on price //f the user enter some tnvalid character then print Invalid option and re-prompt the user to enter an item from the menu // continue this menu based prompt until user enters E if(user_choiceA) cout <How many cups of Coffee would you like? cin > num_cupsi 36 83 compiler Resources th compile L og Debug a Find Results Line: 31 Col: 62 Sel: 0 Lines: 80 Length: 2123 parsing in 0.031 seconds ENG 11:38 AMM

CODE:

#include <iostream>

#include<string>

#include<conio.h>

using namespace std;

int main(){

// declare a char to store the user choice

char user_choice;

do

{

// display the menu to the user

cout << "Hot Beverage Menu: \n" << endl;

cout << "A: Coffee $1.00 " << endl;

cout << "B: Tea $0.75" << endl;

cout << "C: Hot Chocolate $1.25" << endl;

cout << "D: Cappuccino $2.50" << endl;

cout << "E: Exit Menu \n" << endl;

// get the user choice

cout << "Enter your choice: ";

cin >> user_choice;

// declare an int to store the number of cups user want and a double to store the total bill

int num_cups;

double total;

// check the user choice and ask for number of cups and then calculate the total bill based on price

// if the user enter some invalid character then print Invalid option and re-prompt the user to enter an item from the menu.

// continue this menu based prompt until user enters E

if(user_choice == 'A')

{

cout << "How many cups of Coffee would you like? " ;

cin >> num_cups;

  

cout << "Total Bill: $" << num_cups*1 << endl;

}

else if(user_choice == 'B')

{

cout << "How many cups of Tea would you like? " ;

cin >> num_cups;

  

cout << "Total Bill: $" << num_cups*0.75 << endl;

}

else if(user_choice == 'C')

{

cout << "How many cups of Hot Chocoloate would you like? " ;

cin >> num_cups;

  

cout << "Total Bill: $" << num_cups*1.25 << endl;

}

else if(user_choice == 'D')

{

cout << "How many cups of Cappuccino would you like? " ;

cin >> num_cups;

  

cout << "Total Bill: $" << num_cups*2.5 << endl;

}

else if(user_choice == 'E')

{

cout << "Exiting the menu system" << endl;

}

else

{

cout << "Invalid choice" << endl;

}

cout << "\n\n" << endl;

} while(user_choice != 'E');

getch();

return 0;

}

The explanation is provided in form of comments within the code.

Add a comment
Know the answer?
Add Answer to:
Write a program that displays this to the user. "Hot Beverage Menu" "A: Coffee $1.00", "B:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem Statement: Chip’s Snack Bar sells chips ($1), soda ($1.25), hot dogs ($2) and coffee ($0.75)....

    Problem Statement: Chip’s Snack Bar sells chips ($1), soda ($1.25), hot dogs ($2) and coffee ($0.75). Both Seniors (i.e., age >= 62) and Students are eligible for a 10% discount. Seniors are not charged for coffee (regardless of the number ordered). All sales are taxed at a rate of 6%. Write a Java program to do the following: 1. Read in an order from the keyboard ( which contains the student status [y/n], user age, number of chips, number of...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT