Computer Science, asked by NitinArpita, 1 year ago

write a program in java to know whether it is odd or even. plz answer

Answers

Answered by frederickgomespakvin
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.");
}
}
Answered by BrainlyPromoter
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