Pages

Tuesday, July 3, 2012

Find Odd and Even Numbers in java

Write a program to accept a number from the user. Use condition checking statement and display whether the number is odd or even.
class oddEven
{
public static void main(String args[])
{
int num=Integer.parseInt(args[0]);
if(num%2==0)
{
System.out.println("The number "+num+" is EVEN");
}
else
{
System.out.println("The number "+num+" is ODD");
}
}
}

No comments:

Post a Comment