java program for checking even and odd number

Java program for checking even and odd number

import java.util.Scanner;
class Check
{
public static void main ( String []s)
{

Scanner value = new Scanner( System.in);
System.out.println ( " Enter the number : ");
int number = value.nextInt();

if ( number %2 == 0)
{
System.out.println ( " the number "+ number + " is even number ");
}
else
{ System.out.println( " the number is odd " );
}
System.out.println( " using bitwise and operator " );
System.out.println ( " Enter another number ; ");
Scanner abc = new Scanner( System.in );
int number1 = abc.nextInt();
if ( (number1 & 1) == 0)
{
System.out.println ( " it is an even number ");
}
else
{ System.out.println ( " it is an odd number " );
}

}
}

Read More
admin February 18, 2014 0 Comments