home *** CD-ROM | disk | FTP | other *** search
- //: C03:Menu2.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // A menu using a switch statement
- #include <iostream>
- using namespace std;
-
- int main() {
- bool quit = false; // Flag for quitting
- while(quit == false) {
- cout << "Select a, b, c or q to quit: ";
- char response;
- cin >> response;
- switch(response) {
- case 'a' : cout << "you chose 'a'" << endl;
- break;
- case 'b' : cout << "you chose 'b'" << endl;
- break;
- case 'c' : cout << "you chose 'c'" << endl;
- break;
- case 'q' : cout << "quitting menu" << endl;
- quit = true;
- break;
- default : cout << "Please use a,b,c or q!"
- << endl;
- }
- }
- } ///:~
-