void menu_prompt(vector<int> list){
char user_input{};
do {
cout << "P - Print numbers" << endl;
cout << "A - Add a number" << endl;
cout << "M - Display mean of the numbers" << endl;
cout << "S - Display the smallest number" << endl;
cout << "L - Display the largest number" << endl;
cout << "Q - Quit" << endl << endl;
cout << "Enter your choice: " << endl;
cin >> user_input;
} while(user_input != 'P' || 'A' || 'M' || 'S' || 'L' || 'Q' || 'p' || 'a' || 'm' || 's' || 'l' || 'q');
if(user_input == 'P' || 'p'){
user_choice_print_numbers(list);
}
else if(user_input == 'A' || 'a'){
user_choice_add_numbers(list);
}
else if(user_input == 'M' || 'm'){
user_choice_mean_numbers(list);
}
else if(user_input == 'S' || 's'){
user_choice_smallest_numbers(list);
}
else if(user_input == 'L' || 'l'){
user_choice_largest_number(list);
}
else if(user_input == 'Q' || 'q'){
user_choice_quit();
}
}
I have a menu function that I chose to do a do-while loop in order to prompt the menu at least once. Whenever I input the following characters, the menu is prompted again. I have a gut feeling that this issue either has to do with scoping or not manipulating the variable user_input correctly since the do-while loop's escape is based on user_input.
My logic is the "do" part executes the print statements and will prompt for the user to change user_input. If none of the characters shown in the escape statement are inputted, the menu will be prompted again.
I haven't posted the entire program because it's somewhat lengthy and I don't think other parts are affecting this issue. But the gist is certain inputs will call certain functions already created previously.