diff --git a/src/EstructuraRepetitiva3_2.java b/src/EstructuraRepetitiva3_2.java index f13affa..40b3d6b 100644 --- a/src/EstructuraRepetitiva3_2.java +++ b/src/EstructuraRepetitiva3_2.java @@ -5,7 +5,18 @@ public class EstructuraRepetitiva3_2 { static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Introduce un número entero: "); - int n = sc.nextInt(); + + int n = 0; + try{ + n = sc.nextInt(); + } catch (Exception e) { + System.out.println("La lectura de input ha lanzado la exception" + e + "\n"); + } + + if (n <= 4){ + System.out.println("El numero tiene que ser mayor que 4"); + return; + } // si compuestos[n] == true, el número es compuesto boolean[] compuestos = new boolean[n + 1];