Advertisement
cesarnascimento

mostrar numeros impares e pares for

May 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package exercicios;
  2. import java.util.Scanner;
  3. public class ex14 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int numero;
  8.         int par = 0;
  9.         int impar = 0;
  10.        
  11.        
  12.         for(int i = 0; i < 10; i++){
  13.             System.out.println("Digite o número: ");
  14.             numero = sc.nextInt();
  15.             if(numero % 2 == 0){
  16.                 par++;
  17.             }else{
  18.                 impar++;
  19.             }
  20.         }
  21.         System.out.println("Pares: "+par+"\n Impares: "+impar);
  22.     }
  23.  
  24. }
  25.  
  26. //faça um programa que peça 10 numeros inteiros, calcule e mostre a
  27. //quantidade de números pares e a quantidade de números impares.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement