Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EvenOdd
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- System.out.print("Please enter a whole number: ");
- if (in.hasNextInt()) {
- int number = in.nextInt();
- System.out.println(number % 2 == 0 ? "Even" : "Odd");
- } else {
- System.out.println("Not a whole number!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement