write a program in java to know whether it is odd or even. plz answer
Share
write a program in java to know whether it is odd or even. plz answer
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
class Odd_Even
{
public static void main(String args[])
{
int x;
System.out.println("Enter a number : ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if ( x % 2 == 0 )
System.out.println("You entered an even number.");
else
System.out.println("You entered an odd number.");
}
}
import java.util.*;
class Pract
{
public static void Practice()
{
Scanner Promoter = new Scanner(System.in);
System.out.print("Enter the number: ");
double a = Promoter.nextDouble();
if(a%2 == 0)
{
System.out.println("The entered number is even.");
}
else
{
System.out.println("The enetered number is odd.");
}
}
}
Output:
Enter the number: 45
The enetered number is odd.