• Lenguaje

    Java usando Scanner

  • Descripción

    Dado un número entero; determinar si el mismo es par, impar o nulo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Scanner;

public class ParImparONulo {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int numero_entero;
        System.out.print("Ingresa el valor de numero entero: ");
        numero_entero = in.nextInt();
        in.nextLine();
        if(numero_entero!=0&&numero_entero%2==0)
            System.out.println("par");
        if(numero_entero%2==1)
            System.out.println("impar");
        if(numero_entero==0)
            System.out.println("nulo");
    }

}