write a program to input a number and check whether it is even or odd in java
Answers
Answered by
16
import java.util.Scanner;
public class EvenOdd
{
public static void main(String args[])
{
int num;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number:");
num = s.nextInt();
if(num % 2 == 0)
{
System.out.println("Inputted number "+num+" is Even ");
}
else
{
System.out.println("Inputted number "+num+" is Odd ");
}
}
}
HimadriShekhar:
thank you for the answer. hope it helps me
Similar questions