Created
November 11, 2012 22:22
-
-
Save marioplumbarius/4056499 to your computer and use it in GitHub Desktop.
Programa em Java que informa a quantidade de números pares/ímpares digitados pelo usuário.
This file contains hidden or 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
/* | |
* Digite X números e informe quantos números pares/ímpares foram digitados. | |
*/ | |
package cap14; | |
import java.util.Scanner; | |
public class Exercicio08 { | |
public static void main(String[] argss){ | |
Scanner ent = new Scanner(System.in); | |
int num, contPar = 0, contImpar = 0; | |
for(int i = 1; i <= 5; i++){ | |
System.out.println("Digite o " + i + "º número"); | |
num = ent.nextInt(); | |
if(num % 2 == 0){ | |
contPar++; | |
} | |
// para informar números impares | |
/* | |
if(num % 2 == 1){ | |
contImpar++; | |
} | |
*/ | |
} | |
System.out.println("Foram digitados " + contPar + " números pares \n"); | |
// System.out.println("E " + contImpar + " números ímpares"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Muito bom !!