/**********************************************************/
//switch2.cpp
//R. A. Hillyard
//Last Modified 09/24/2001
//
//This program demonstrates the use of the switch statement
//Print a message based on user input
/*********************************************************/
#include<iostream>
using namespace std;
int main()
{
char choice; //holds user choice
bool flag = true; //flag for loop
do
{
//print menu of choices and get user choice
cout << "\n\nPlease choose one of the following\n";
cout << "1\t for red\n";
cout << "2\t for green\n";
cout << "3\t for blue\n";
cout << "4\t for quit\n\n";
cin >> choice; //get user choice
switch(choice)
{
case '1':
cout << "You picked red\n";
break;
case '2':
cout << "You picked green\n";
break;
case '3':
cout << "You picked blue\n";
break;
case '4':
cout << "You picked quit\n";
flag = false;
break;
default :
cout << choice << " is not a valid entry - try again\n";
}//end switch
}while(flag == true);
return 0;
}//end main
/**********************************************************
Please choose one of the following
1 for red
2 for green
3 for blue
4 for quit
1
You picked red
Please choose one of the following
1 for red
2 for green
3 for blue
4 for quit
2
You picked green
Please choose one of the following
1 for red
2 for green
3 for blue
4 for quit
4
You picked quit
*/