-
-
Save parzibyte/e52a5297005ab4eca2db438f235b0bfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void sumaParesImpares() { | |
int sumaPares = 0; | |
int sumaImpares = 0; | |
Scanner sc = new Scanner(System.in); | |
for (int i = 0; i < 10; i++) { | |
System.out.printf("Ingresa un número entero (%d de 10): ", i + 1); | |
int numero = sc.nextInt(); | |
if (numero % 2 == 0) { | |
sumaPares += numero; | |
} else { | |
sumaImpares += numero; | |
} | |
} | |
sc.close(); | |
System.out.printf("Resultado: Total pares: %d; Total impares: %d", sumaPares, sumaImpares); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment