/**********************************************************/
//switch3.cpp 
//R. A. Hillyard
//Last Modified 09/24/2001
// 
//This program demonstrates what happens if you forget
//to use a break statement for each case 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";
    
    cin >> choice;    //get user choice
    
    switch(choice)
      {
      case '1':
        cout << "You picked red\n";
      
      case '2':
        cout << "You picked green\n";
              
      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

/*********************Program Output***************
Please choose one of the following
1	 for red
2	 for green
3	 for blue
4	 for quit

>1
You picked red
You picked green
You picked blue


Please choose one of the following
1	 for red
2	 for green
3	 for blue
4	 for quit

>2
You picked green
You picked blue


Please choose one of the following
1	 for red
2	 for green
3	 for blue
4	 for quit

>4
You picked quit
*/