Does not enter the method

0

When running the program does not do what is in the method. I still do not find the error, I think it's something quite simple but I can not see it. Here the code

public class Ejercicio5 {
 public Ejercicio5(){  
 }
 public static void Par (){
       int a;
 Scanner leer = new Scanner(System.in);
     System.out.println("Dame un numero");
     a=leer.nextInt();

     if(a%2<0){
         System.out.println("Es par");
     }
     else{
         System.out.println("No es par");
     }
 }
}

    package ejercicios;
import java.util.Scanner;
public class Ejercicios {
    public static void main(String[] args) {
        Ejercicio5.Par();  
    } 
}
    
asked by Erick 14.08.2018 в 20:55
source

1 answer

0

I just had to change the condition and import the Scanner into the main.

package Ejercicios;

import java.util.Scanner;

public class Ejercicio5 {
  public static void Par(){
    int a;
    Scanner leer = new Scanner(System.in);
    System.out.println("Dame un numero");
    a=leer.nextInt();

    if(a%2==0){
      System.out.println("Es par");
    } else {
      System.out.println("No es par");
    }
  }
}
    
answered by 14.08.2018 в 21:23