Conditional Constructs 2

Description

The purpose of this challenge is to use if, if-else, if-else-if and switch statements. This challenge simulates a menu system.

Requirements

      1. Declare a string called size. Initialize this to a blank string (a pair of double quotes with nothing between them)
      2. Declare a double called ouncesInitialize 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.

DO NOT USE

Loops for your menu

Sample Interaction / Output

How many ounces do you like? 16
What type of drink?
c - Carbonated
j - Juices
q - Cancel/Quit
Choice: c

What drink?
p - Dr. Pepper
s - Squirt
f - Fanta
Choice: f

You got a Medium Fanta

RUN IT AGAIN

How many ounces do you like? 10
What type of drink?
c - Carbonated
j - Juices
q - Cancel/Quit
Choice: j

What juice?
o - Orange
p - Pomegranate
g - Guava
Choice: g

You got a Small Guava Juice

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-COND0002

Print Requirements