I'm doing a kind of menu for a calculator in java, with a switch I have to choose between 3 values (1, 2 and 3) and inside case 1, I make another switch to choose the submenus (a, b, c and d) ), my problem is that I need that if you enter a value that is not valid (A value other than a, b, cod) ask me again for a valid value by keyboard, in the first menu I got it with an if (If not the value is not 1 or 2 or 3) and a do-while (As long as the value is different from 1, 2 or 3 it asks for a value again per keyboard) But in the submenu I can not make it work in the same way. I attach a screenshot. Thanks in advance. link
System.out.println("a. Suma");
System.out.println("b. Resta");
System.out.println("c. Producto");
System.out.println("d. División");
opcion = keyboard.nextLine();
char b = opcion.charAt(0);
if ( b != 'a' || b != 'b' || b != 'c' || b != 'd' )
do {
System.out.println("Introduce un valor valido");
opcion = keyboard.nextLine();
b = opcion.charAt(0);
} while ( b != 'a' || b != 'b' || b != 'c' || b != 'd' );
switch (b) {
case 'a':
I want that if I enter by letter the letter a, b, c or d, do not enter inside the if and the if loop, with this code write what you type on the keyboard the program enters inside the loop and never comes out. I just want to get inside the if and the loop if you write anything other than a, b, c and d.