In: Computer Science
Use a switch statement to create a menu with the following options
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.
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: