Question: need this in c++ Declare a string called size. Initialize this to a blank string (a pair of double quotes with nothing between them) Declare
need this in c++
- Declare a string called size. Initialize this to a blank string (a pair of double quotes with nothing between them)
- Declare a doublecalled ounces. Initialize this to 0 (zero).
- Ask the user to input a value for ounces. (cout-cin combo)
- Use an if-else-if construct to set the value of size. Remember that size is a string variable. Check the value of ounces and set size as below:
- If the value of ounces is between 1 and 12, set size to Small
- If the value of ounces is greater than 12 but less than or equal to 24, set size to Medium
- If the value of ounces is greater than 24, set size to Large
- Declare a char called choice
- Declare a char called drink_type
- Declare a string called drink
- Write an if statement that checks size to see if it is blank as below
if (size == "") { // A } else { // B } - Inside the block marked A above, write a message indicating that an invalid size was picked or something to that effect
- Inside the block marked B above, ask the user to enter a choice using a menu. Your cout statement will show the message below, and you will use cin to receive the user input into drink_type
c - Carbonated j - Juices q - Cancel/Quit
- Using a switch statement, ask the user to select a drink. For example, inside the choice for c Carbonated, write another menu to ask the user to pick the drink. Use cin to receive the user input into choice. Set the value of drink accordingly. Use the below as a guide.
switch (drink_type) { case 'c': // carbonated cout << "What fizzy drink do you like?"; cin >> choice; // here's another menu (nested switch) switch (choice) { case 'p': drink = "Dr Pepper"; break; } case 'j': // create another menu here for juices } - Create 3 choices of drinks for each of Carbonated and Juices. You determine what case values are appropriate and usable for the drinks that you choose. Notice how the example above used p for Dr Pepper feel free to pick any drinks and menu choice entries you like
- Then, show a message showing the final selections indicating size and drink. For example, an output might be Medium Dr. Pepper.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
