write a program in java to know whether it is odd or even. plz answer
Answers
Answered by
1
import java.util.Scanner;
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.");
}
}
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.");
}
}
Answered by
0
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.
Similar questions
Math,
8 months ago
English,
8 months ago
Physics,
8 months ago
Social Sciences,
1 year ago
History,
1 year ago