Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description (It has to work with C++ Thank you). The purpose of this challenge is to use if, if-else, if-else-if and switch statements. This challenge

Description (It has to work with C++ Thank you).

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

Requirements

Declare a string called size. Initialize this to a blank string (a pair of double quotes with nothing between them)

Declare a double called 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

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions