Java Program To Find Last Digit Of a Number is Even Or Odd.

 

Find Last Digit Of  Number is Even Or Odd.


import java.util.*;

class FirEvenOdd
{
    public static void main(String[] args)
    {
        Scanner sc= new Scanner(System.in);
        System.out.println("Enter a number");
        int n=sc.nextInt();
        while(n>=10)
        {
            n=n%10;
           
        }
        if(n%2==0)
        {
            System.out.println(n+ " is even");
        }
        else
        {
            System.out.println(n+ " is odd");
        }
    }
}

Popular posts from this blog

In this problem, you will practice your knowledge on interfaces - Hacker Rank Solution.

Find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.

Query the Name of any student in STUDENTS who scored higher than 75 Marks - Hacker Rank Solution.