Write a Java Program to Check Whether the entered number is Even or Odd.

Q.9 Write a Java Program to Check Whether the entered number is Even or Odd.

Solution  :- 

import java.util.*;
class even_odd   
{
    public static void main(String args[])
    {
        int no1; 
        Scanner out = new Scanner(System.in);
        System.out.println(“Enter the first number :- “);
        no1 = out.nextInt();
        if(no1 % 2 == 0)
        {
            System.out.println(“It is Even number :- “+no1);
        }
        else
        {
            System.out.println(“It is Odd number :- “+no1);   
        }
    }
} 

Solution  :- 

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.