Java - ejercicio de arreglo

 
Vista:
sin imagen de perfil

ejercicio de arreglo

Publicado por katerin (2 intervenciones) el 03/08/2015 16:11:58
programa de arreglo que muestra 20 numeros y los capture y hace la revisión de ellos para indicar cuantos son pare y cuantos son impares

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static void main(String[] args) {
       Scanner captura=new Scanner(System.in);
        int num[] =new int[20];
        for (int x=0;x<=19;x++){
        System.out.print("ingrese el numero:");
        num[x]=captura.nextInt();
        }
         for (int x=0;x<=19;x++){
        int mood ;
        mood =num[x]%2;
        if(mood==0)
          System.out.println("pares" + num[x]);
        }
          for (int x=0;x<=19;x++){
        int mood ;
         mood =num[x]%2;
        if(mood !=0)
          System.out.println("impares" + num[x]);
 
        }
    }
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder