WAP to check given number is odd or even.



import java.io.DataInputStream;
class OddOrEven
{
    public static void main(String args[])
    {
        int  i,a;
        System.out.println("Enter the number:");   
        try
        {
            DataInputStream obj=new DataInputStream(System.in);
                a = Integer.parseInt(obj.readLine());
            if(a%2==0)
            {
                System.out.println("The numeber is Even ->"+a);   
            }   
            else
            {
                System.out.println("The numeber is Odd ->"+a);
            }
        }
        catch(Exception e)
        {
            System.out.print("not valid" +e);
        }
       
    }
}

0 comments:

Post a Comment

Digital Marketing

Subscribe to RSS Feed Follow me on Twitter!