write a program in java to input from the user and find if the number is even or odd.
Answers
class Even_odd
{
public static void main (int n )
{
if(n%2==0)
System.out.println("Even number");
else
System.out.println("Odd number");
}
}
Mark me brainlest.
for more doubts ask me and follow me.
Answer:
import java.io.*;
import java.util.*;
class odd_even //user defined
{
public static Scanner sc= new Scanner(System.in);
public static void main(String args[])
{
int number; //user defined
System.out.println("Enter the number"); //To get input
number=sc.nextInt();
if(number%2==0) //To check whether the number is odd or even
System.out.println("Number = "+number+"\nODD/EVEN : EVEN Number"); //output
else //If firtst statement fails to prove the given number is Even
System.out.println("Number = "+number+"\nODD/EVEN : ODD Number"); //output
}
}