Computer Science, asked by qwerty01, 11 months ago

write a java program to check a entered no. is odd or even

Answers

Answered by priyanshikakatyayan
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 !!!
Answered by vageeshgn2005
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