Java programme to print number is even or odd with the method concept.

For practice copy the code below.

// Nileshdeoree.blogspot.com

package Nileshdeore;
import java.util.Scanner;
public class evenodd  
{
   
    public static void main (String args[])
    {
        Scanner input= new Scanner (System.in);
        System.out.println("Enter the number  ");
        int num =input.nextInt();
        
        even_odd(num);  // Calling method
    }
   
     static void even_odd(int num)
    {   
      if(num%2==0)
         System.out.println (num+" is even");
      else 
          System.out.println (num+" is odd");
       }    
     
}









Comments

Popular posts from this blog

Create an array of 5 floats and calculate their sum in java .