-
-
Save parzibyte/2d6d9015d2b7eec19ff554828ef63c4d 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); | |
} | |
public static void main(String[] args) { | |
sumaParesImpares(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment