home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / source / chapter02 / menu_chooser.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-10-21  |  556 b   |  34 lines

  1. // Menu Chooser
  2. // Demonstrates the switch statement
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main() 
  8. {
  9.     cout << "Difficulty Levels\n\n";
  10.     cout << "1 - Easy\n";
  11.     cout << "2 - Normal\n";
  12.     cout << "3 - Hard\n\n";
  13.  
  14.     int choice;
  15.     cout << "Choice: ";
  16.     cin >> choice;
  17.  
  18.     switch (choice)
  19.     {
  20.     case 1:    
  21.             cout << "You picked Easy.\n";
  22.             break;
  23.     case 2:    
  24.             cout << "You picked Normal.\n";
  25.             break;
  26.     case 3:    
  27.             cout << "You picked Hard.\n";
  28.             break;
  29.     default:
  30.             cout << "You made an illegal choice.\n";
  31.     }
  32.  
  33.     return 0;
  34. }