#include <iostream>
#include <cctype>
//Forward Declarations
void menu();
void select_M();
void select_A();
void select_C();
void select_N();
void select_E();
char isValid(char &);
void selection_error();
//MAIN
int main(){
menu();
return 0;
}
//MAIN MENU
void menu(){
char selection{}; //declares and initiallizes selection to null
std::cout << "(M) Selection 1" << std::endl;
std::cout << "(A) Selection 2" << std::endl;
std::cout << "(C) Selection 3" << std::endl;
std::cout << "(N) Selection 4" << std::endl;
std::cout << "(E) Selection 5" << std::endl;
std::cout << "(Q) Quit" << std::endl;
std::cout << std::endl;
std::cout << "Enter your selection: ";
isValid(selection);
switch(selection){
case 'M': select_M(); break;
case 'A': select_A(); break;
case 'C': select_C(); break;
case 'N': select_N(); break;
case 'E': select_E(); break;
case 'Q': return; //break;
default: selection_error(); break;
}//switch
system("cls"); //used for testing - not recommended for use in actual program
menu();
}//menu
//INPUT VALIDATION
char isValid(char &selection){
std::cin >> selection;
selection = toupper(selection); // ctype.h for toupper changes all to uppercase characters
//checks to see if more than 1 character is inputed
if (std::cin.get() != '\n'){
std::cin.ignore(256, '\n'); //ignores 256 chars until newline('\n')
std::cin.clear(); // clears the input
selection = '\0'; // sets selection to null
system("cls");//used for testing - not recommended for use in actual program
}
return selection;
}
void selection_error(){
std::cout << "Invaild Selection"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}
void select_M(){
std::cout << "M was Selected"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}
void select_A(){
std::cout << "A was Selected"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}
void select_C(){
std::cout << "C was Selected"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}
void select_N(){
std::cout << "N was Selected"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}
void select_E(){
std::cout << "E was Selected"<< std::endl;
system("pause"); //used for testing - not recommended for use in actual program
}