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

Develop an object oriented program in C++ to create a database of student information system containing the following information: Name, Roll number, Class, division, Date of Birth, Blood group, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz constructor, default constructor, Copy constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.

Java Program For Find Addition Of First and Last Digit Of Number.