Skip to content

Instantly share code, notes, and snippets.

@NickersF
Created January 10, 2016 08:19
Show Gist options
  • Save NickersF/80f808464478cf7be9b2 to your computer and use it in GitHub Desktop.
Save NickersF/80f808464478cf7be9b2 to your computer and use it in GitHub Desktop.
CS162 Project 2: Prototype of the menu for project 2
// Author: Nicholas Fazzolari
// Date: 1/9/16
// Assignment:
#include <iostream>
using namespace std;
// menu function (prototype)
void userMenu();
int main() {
userMenu();
return 0;
}
// menu function
void userMenu() {
bool controlMenuLoop = true;
int menuSelection = 0;
// old loop
while (controlMenuLoop && cin.good()) {
cout << "******** Main Menu ********" << endl;
cout << "[1] - Option 1: " << endl;
cout << "[2] - Option 2: " << endl;
cout << "[3] - Option 3(quit): " << endl;
cin >> menuSelection;
switch (menuSelection) {
case 1:
cout << "Menu option 1 selected" << endl;
break;
case 2:
cout << "Menu option 2 selected" << endl;
break;
case 3:
cout << "Menu option 3 selected" << endl;
break;
default:
cout << "Invalid selection." << endl;
controlMenuLoop = true;
}
if (menuSelection == 3) {
controlMenuLoop = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment