Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with a C++ project. Here are the instructions. An output sample of what the program should look like is included at the bottom.

Need help with a C++ project. Here are the instructions. An output sample of what the program should look like is included at the bottom. Please follow all instructions.

image text in transcribedimage text in transcribed

Output sample below:

image text in transcribed

1. Problem Statement: The goal of this assignment is to get you familiar with two types of conditional statements: if statements and switch statements. Your task is to write a C++ program that displays a menu to the user asking them to select a beverage of choice. Once the user has entered their choice, display a message asking for the size of beverage. The choice of soda and the choice of size can be done with separate cin statements. Once the choice of soda and size have been obtained, the price of the soda/size selected must be displayed. Use the following data to implement this menu. - Coke - $1.5020oz or $1.75 2Liter - Pepsi - $1.0020oz or $2.00 2Liter - Mt. Dew - \$.75 20oz or \$1.90 2Liter - Dr. Pepper $1.2520oz or $2.252 Liter 2. Description Your first task is to design your beverage menu. It is not convenient to have the user type in the full names of products "Coke" or "Pepsi", so you need to choose short codes for each of these products (e.g. 1,2,3,4 or A,B,C,D). After getting and validating the beverage selection, you will prompt for the size of beverage. You will also validate the user input. After all of this data is inputted, you must use a switch statement to handle the user's input and the appropriate output. To process this data, you are required to use an if-else statement to print a different message depending on the soda and size. For example, if the user chooses a 20oz Dr. Pepper the message could be "You owe $1.25 ". Finally, when your program is working you need to add error handling capabilities to your program. You need to decide what should happen if the user types in an illegal menu choice. What will happen if they type in an incorrect soda size? You need to extend the switch statement and the if-else statements to handle these input errors. 3. Implementation: You can implement this program using either a bottom-up approach or a top-down approach. If you go for a bottom-up approach, start by creating basic methods and classes, and test theses methods using a simple main program that calls each method. When this is working, you can create the main program that uses these methods to solve the problem above. If you go for a top-down approach, start by creating your main program that reads user input, and calls empty methods to pretend to solve the problem. Then add in the code for these methods one at a time. This way, you will get an idea of how the whole program will work before you dive into the details of implementing each method and class. Regardless of which technique you choose to use, you should develop your code incrementally adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete. 4. Testing: Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Save your testing output in text files for submission on the program due date. For debugging purposes, it is useful to "echo" any variables you input, and to print intermediate results as they are calculated. You should comment out your debugging code before you hand in your final version of the program. Softdrink Selection Menu Coke 1 Pepsi 2 Mt. Dew 3 Dr. Pepper 4 Enter Choice: 1 What size of beverage would you like (B - 20oz bottle, L - 2 liter): B Coke was selected, size is 20 oz bottle, you owe: $1.50 Program exiting Sample output with bad data: Softdrink Selection Menu Pepsi 2 Dr. Pepper 4 Enter Choice: 5 Invalid selection, please try again Softdrink Selection Menu Coke 1 Pepsi 2 Mt. Dew 3 Dr. Pepper 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions