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.
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 the user input, you must use a switch statement to handle the user's input. For example, if you use letters for menu items and the user types in 'A' then you know they want to buy a Coke.
Your second task is to design the "size of beverage" interaction. What message to print to the screen? What value to read from the user? 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.
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.
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. Try your program on 2-3 input values, and save your testing output in text files for inclusion in your project report.
When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.
In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "upload" your documentation (a single pdf or txt file), and your C++ program (a single cpp or txt file). Do NOT upload an executable version of your program.
The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit: