SHARE
TWEET

EvenOdd

a guest Feb 17th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class EvenOdd
  4. {
  5.   public static void main(String[] args)
  6.   {
  7.     Scanner in = new Scanner(System.in);
  8.     System.out.print("Please enter a whole number: ");
  9.     if (in.hasNextInt()) {
  10.       int number = in.nextInt();
  11.       System.out.println(number % 2 == 0 ? "Even" : "Odd");
  12.     } else {
  13.       System.out.println("Not a whole number!");
  14.     }
  15.  
  16.   }
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top