write a java program to check a entered no. is odd or even
Answers
Answered by
4
import java.util.*;
class number
{
public static void main ( String args[ ] )
{
int a;
if( a%2 = = 0)
{
System.out.println(" Even number" );
}
else
System.out.println (" Odd number " );
}
}
HOPE IT HELPS YOU !!!
class number
{
public static void main ( String args[ ] )
{
int a;
if( a%2 = = 0)
{
System.out.println(" Even number" );
}
else
System.out.println (" Odd number " );
}
}
HOPE IT HELPS YOU !!!
Answered by
1
Answer:
i am using Scanner class
Explanation:
import java.util.Scanner;
public class evod
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int num = sc.nextInt();
if(num%2 ==0) //if condition
{
System.out.println("The number you entered is Even");//(to print even if the remainder is 0)
}
else
{
System.out.println("The number you entered is odd");//(prints off if the remainder is not 0)
}
}
}
Similar questions