반응형
Program:
import java.util.Scanner;
class OddOrEven
{
public static void main(String args[])
{
int x;
System.out.println("Enter an integer to check if it is odd or even");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if (x % 2 == 0)
System.out.println("The number is even.");
else
System.out.println("The number is odd.");
}
}
Output:
Enter an integer to check if it is odd or even
5
The number is odd.
Enter an integer to check if it is odd or even
8
The number is even.
'Learn java app' 카테고리의 다른 글
Program to Illustrate Enhanced For Loop (0) | 2020.06.22 |
---|---|
Program to Print Multiplication Table (0) | 2020.06.22 |
Program to know the functionality of Static Block (0) | 2020.06.22 |