1: //shell.cpp
2: //Acts as a general-purpose "shell" program.
4: #include <iostream>
5: using namespace std;
7: int main()
8: {
9: int menuChoice;
10: do
11: {//Body of do...while-statement must be enclosed in braces
12: cout << "\n\n\t\t" << "Main Menu"
13: "\n\n\t\t" << "1. Quit"
14: "\n\t\t" << "2. Get information"
15: "\n\t\t" << "3. Perform some action"
16: "\n\t\t" << "4. Perform some other action\n\n";
18: cout << "Enter the number of your menu choice here "
19: "and then press the Enter key: ";
20: cin >> menuChoice; cin.ignore(80, '\n');
21: cout << endl << endl;
23: //A break-statement within a switch-statement causes a "jump"
24: //to the first statement following the switch-statement.
25: switch (menuChoice)
26: {//Body of switch-statement must be enclosed in braces
27: case 1: //Do this if menuChoice is 1.
28: cout << "You have chosen to quit. "
29: "Program is now terminating.\n";
30: break;
32: case 2: //Do this if menuChoice is 2.
33: cout << "This program can be used as a starting point "
34: "for many C++ programs.\nA general description of "
35: "whatever your program does should go here.\n";
36: break;
38: case 3: //Do this if menuChoice is 3.
39: cout << "Now performing some action in response "
40: "to user choosing menu option 3 ...\n";
41: break;
43: case 4: //Do this if menuChoice is 4.
44: cout << "Now performing some action in response "
45: "to user choosing menu option 4 ...\n";
46: break;
47: }
48: cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
50: } while (menuChoice != 1); //While user does not choose quit option
51: cout << endl << endl;
52: }