Question

In: Computer Science

Use a switch statement to create a menu with the following options Create a Camping Trip...

Use a switch statement to create a menu with the following options

  1. Create a Camping Trip
  2. Assign a Camper to a Trip
  3. Create a Needed Food item
  4. Assign a Camper to a Food item

For now just print a message prompting user for input and allowing them to return the menu. No functionality is required at this time, but save this code for later use.

Solutions

Expert Solution

For this program, we display the menu to the user and ask him to select the option. The switch statement displays the corresponding message to the choice of the user. Then prompts the menu again to the user, until he enters an exit condition input.

CODE:

#include <iostream>
#include<stdlib.h>

using namespace std;

int main()
{
int choice;
for(;;){
cout<<"\n1. Create a Camping Trip\n2. Assign a Camper to a Trip\n3. Create a Needed Food item\n4. Assign a Camper to a Food item";
cout<<"\nEnter your choice from the menu: ";
cin>>choice;
switch(choice)
{
case 1: cout<<"choice 1 selected";
break;
case 2: cout<<"choice 2 selected";
break;
case 3: cout<<"choice 3 selected";
break;
case 4: cout<<"choice 4 selected";
break;
default: cout<<"option for invalid input/ exit condition!";
exit(0);
}
}

return 0;
}

OUTPUT:


Related Solutions

Use C++ to create an application that provide the menu with two options TemperatureConverter_Smith.cpp MENU CONVERTER...
Use C++ to create an application that provide the menu with two options TemperatureConverter_Smith.cpp MENU CONVERTER TEMPERATURE – JAMES SMITH Convert Fahrenheit temperature to Celsius Convert Celsius temperature to Fahrenheit Exit CASE 1: Convert Fahrenheit temperature to Celsius -Display the message to ask to enter Fahrenheit degree from the keyboard -Use the following formula to convert to Celsius degree         Celsius Temperature = (Fahrenheit Temperature – 32) * 5/9 ; -Display the output as below: TemperatureConverter_Smith.cpp TEMPERATURE CONVERTER – JAMES...
Create a menu in Java. A menu is a presentation of options for you to select....
Create a menu in Java. A menu is a presentation of options for you to select. You can do this in the main() method. 1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Buy Stock. B. Sell Stock X. Exit Enter your Selection: 3. Prompt for the value menuChoice....
create a menu in Java. A menu is a presentation of options for you to select....
create a menu in Java. A menu is a presentation of options for you to select. The article above that is in our discussion board may be helpful. You can do this in the main() method. 1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Buy Stock. B. Sell...
Class, Let's create a menu in Java. A menu is a presentation of options for you...
Class, Let's create a menu in Java. A menu is a presentation of options for you to select. You can do this in the main() method. 1. Create a String variable named menuChoice. 2. Display 3 options for your program. I recommend using 3 System.out.println statements and a 4th System.out.print to show "Enter your Selection:". This needs to be inside the do -- while loop. A. Deposit Cash. B. Withdraw Cash X. Exit Enter your Selection: 3. Prompt for the...
No Global variables No goto statement No break outside switch Write a menu driven C program...
No Global variables No goto statement No break outside switch Write a menu driven C program using functions and switch. Feel free to use “Empty Outlines” template from Canvas to design the functions as needed to build the code. Make sure to submit your work through Canvas. You can show me your code running in class when you are done. The program shows following menu to the user repetitively until user selects option 3 to exit. Circle Triangle Exit Based...
You are off on a camping trip to the high sierra with a group of friends...
You are off on a camping trip to the high sierra with a group of friends and one of them relays that they are scared of getting Giardia. Actually, the correct medical term is giardiasis. Fresh from a microbiology class you want to help them and proceed with a lively description of (a) the life cycle (be sure to include animal hosts), (b) symptoms one might experience if infected, (c) the availability of drugs should someone happen to contract the...
Sid and Nancy were on a camping trip to Baxter Island. They had reservations on a...
Sid and Nancy were on a camping trip to Baxter Island. They had reservations on a ferry for themselves and their car. Because they had their two mountain bikes mounted upright and on a roof rack on their car, they had to use a special lane which was also designated for motor homes, vans, and other high profile vehicles. They were parked behind a motor home. During the crossing most drivers left their cars and went on deck. When the...
Use a switch statement to write a function that returns TRUE if a character is a...
Use a switch statement to write a function that returns TRUE if a character is a consonant and returns FALSE otherwise.
You are planning a May camping trip to Denali National Park in Alaska and want to...
You are planning a May camping trip to Denali National Park in Alaska and want to make sure your sleeping bag is warm enough. The average low temperature in the park for May follows a normal distribution with a mean of 32°F and a standard deviation of 8°F. 1. What is the probability that the low temperature on a given night will be between 22°F and 29°F? Include 4 decimal places in your answer. 2. What temperature must the sleeping...
Bill rides the subway at a cost of $.75 per trip but would switch if the...
Bill rides the subway at a cost of $.75 per trip but would switch if the price were any higher. His only alternative is a bus that takes five minutes longer, but costs only $.50. His only alternative is a bus that takes five minutes longer but costs only $.50. He makes 10 trips a year. The city is considering renovations of the subway system that will reduce the trip by 10 minutes, but fares would rise by $.40 per...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT