It seems this code keeps somewhat falling through. Once it gets to the if statement, the if statement no matter what you enter always returns a true value, and follows through. My aim is a simple is this correct question with the user entering Y or N (y or n is also acceptable) but no matter what I type in the if condition seems to return true? If someone could give me some pointers, I would be very grateful!
Code:
int starting_menu()
{
int Menu_Selection;
string Menu_Confirm;
cout << "Welcome to " << Program_Header << " Version: " << Program_Version << endl;
cout << " " << endl;
cout << "Please select from the following options to continue." << endl;
cout << " " << endl;
cout << "1. (Enter Selection one here)" << endl;
cout << "2. (Enter Selection two here)" << endl;
cout << "3. (Enter Selection three here)" << endl;
cout << "Selection: ";
cin >> Menu_Selection;
cin.ignore();
cout << "You selected: " << Menu_Selection << endl;
cout << "Is this correct? (Y/N): " << endl;
cin >> Menu_Confirm;
cin.ignore();
if ( Menu_Confirm == "Y" || "y" )
{
switch ( Menu_Selection )
{
case 1:
cout << "Case 1 Goes Here." << endl;
break;
case 2:
cout << "Case 2 Goes Here." << endl;
break;
case 3:
cout << "Case 3 Goes Here." << endl;
break;
}
}
else if ( Menu_Confirm == "N" || "n" )
{
cout << "Rebooting the Main Menu." << endl;
cin.get();
cout << "Menu System Sucessfully Reloaded." << endl;
starting_menu();
}
else
{
cout << "You have not entered a valid input, please try again." << endl;
cout << "You Selected: " << Menu_Selection << endl;
cout << "Is this correct? (Y/N): ";
cin >> Menu_Confirm;
cin.ignore();
}
}
Happy coding!