In C++: Define a global enumerator RUN_MODE for modes ENCYRPT=1, UNENCRYPT=2, EX
ID: 3713000 • Letter: I
Question
In C++:
Define a global enumerator RUN_MODE for modes ENCYRPT=1, UNENCRYPT=2, EXIT=3.
getRunMode – Displays the user menu, then inputs and returns the run mode selected. You will need to read in to an integer variable and cast the variable to a RUN_MODE to return the enumerator value.
?Mine code follows but doesn't seem to work:
enum RUN_MODE { encrypt = 1, decrypt = 2, exit = 3 };
int getRunMode() {
int menuInput;
cout << "Select the run mode:" << endl;
cout << " 1.) Encrypt" << endl;
cout << " 2.) Decrypt" << endl;
cout << " 3.) Exit" << endl;
cin >> menuInput;
RUN_MODE(menuInput);
return menuInput;
Explanation / Answer
There you go buddy
I just enhanced your code
Here it is
Any problem ask in comments
#include <iostream>
using namespace std;
enum RUN_MODE { encrypt = 1, decrypt = 2, exits = 3 };
int getRunMode() {
int menuInput;
cout << "Select the run mode:" << endl;
cout << " 1.) Encrypt" << endl;
cout << " 2.) Decrypt" << endl;
cout << " 3.) Exit" << endl;
cin >> menuInput;
return RUN_MODE(menuInput);
}
int main(){
getRunMode();
}