bluej Programs
1.Write a program to check whether the number is even or odd.
import java.util.*;
class even_odd
{
void main()
{
Scanner sc=new Scanner(System.in);
int n;
System.out.println("Enter a number:");
n=sc.nextInt();
if(n%2==0)
System.out.println("Even");
else
System.out.println("Odd");
}
}
Output:
Enter a number: 23 Odd
ADVERTISEMENT
