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++
  1. Declare a string called size. Initialize this to a blank string (a pair of double quotes with nothing between them)
  2. Declare a doublecalled ounces. Initialize this to 0 (zero).
  3. Ask the user to input a value for ounces. (cout-cin combo)
  4. 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:
    1. If the value of ounces is between 1 and 12, set size to Small
    2. If the value of ounces is greater than 12 but less than or equal to 24, set size to Medium
    3. If the value of ounces is greater than 24, set size to Large
  5. Declare a char called choice
  6. Declare a char called drink_type
  7. Declare a string called drink
  8. Write an if statement that checks size to see if it is blank as below
    if (size == "") { // A } else { // B } 
  9. Inside the block marked A above, write a message indicating that an invalid size was picked or something to that effect
  10. 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 
  11. 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 } 
  12. 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
  13. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!