Greetings people. I'm starting with Java and doing an exercise testing the do_while I do not know at what point I'm failing. The intention of the loop is that if the user enters a value lower than 1 or higher than 4, the program will ask the user to re-enter the value.
If I leave you like this, when you enter a correct value you should ask again to enter the number but, as it seems, the loop is cut off.
The point is that I've tried and if I just leave a condition in while it works fine for me but when I put the & & amp; Something fails me.
Am I failing in something or is it that the while can not contain multiple conditions?
Thanks in advance.
public class Act6_4 {
public static void main(String[] args) {
//Declaración de variables
int estacion=50;
Scanner teclado = new Scanner (System.in);
//Empieza el bucle por si el usuario introduce un número fuera del rango de opciones
do {
//Muestra mensaje en pantalla pidiendo al usuario que introduzca un número del 1 al 4
System.out.println("Introduce número de estación (1 al 4)");
estacion = teclado.nextInt();
//Empieza la condición con varias opciones
switch (estacion) {
case 1: System.out.println("Verano");
break;
case 2: System.out.println("Otoño");
break;
case 3: System.out.println("Invierno");
break;
case 4: System.out.println("Primavera");
break;
}
} while (estacion<=0 && estacion>=5);
}
}