Check whether a number is even or odd
Sample Output
Check whether a number is even or odd. Enter a number: 11 11 is odd number.
Java-Source Code
//package ifelsejava;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int number;
Scanner input = new Scanner(System.in);
System.out.println("Check whether a number is even or odd.\n");
System.out.print("Enter a number: ");
number = input.nextInt();
if (number % 2 == 0) {
System.out.println(number + " is even number.");
}else {
System.out.println(number + " is odd number.\n");
}
}
}
Sample Output
Check whether a number is even or odd. Enter a number: 96 96 is even number.
No comments:
Post a Comment