StefanTobler

Lesson 11 Activity 4

Sep 25th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. /*
  2.  * Lesson 11 Coding Activity 4
  3.  * Test if an integer input from the keyboard is odd or even.
  4.  *
  5.  *     Sample Run 1:
  6.  *        Enter a Number:
  7.  *        78
  8.  *        Even
  9.  *
  10.  *     Sample Run 2:
  11.  *        Enter a Number:
  12.  *        17
  13.  *        Odd
  14.  *
  15.  */
  16.  
  17. import java.io.*;
  18. import java.util.Scanner;
  19. import java.lang.Math;
  20. import static java.lang.System.*;
  21.  
  22.  
  23. class Lesson_11_Activity_Four {  
  24. public static void main(String[] args)
  25.    {
  26.        Scanner scan = new Scanner(System.in);
  27.        
  28.        System.out.println("Enter a Number:");
  29.        
  30.        int x = scan.nextInt();
  31.        
  32.        if(x%2 == 0){
  33.          System.out.println("Even");
  34.        }
  35.        else{
  36.          System.out.println("Odd");
  37.        }
  38.          
  39.          scan.close();
  40.        
  41.     }
  42. }
Add Comment
Please, Sign In to add comment