Advertisement
EntropyStarRover

Untitled

Apr 25th, 2017
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by entropy on 4/25/2017.
  5.  */
  6. public class odd {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner (System.in);
  9.         int n = 0;
  10.         System.out.print("Enter even number: ");
  11.         try{
  12.             n= Integer.parseInt(scanner.nextLine());
  13.         }catch (Exception e){
  14.             System.out.println("Invalid number!");
  15.         }
  16.  
  17.         while (n%2!=0) {
  18.  
  19.             System.out.println("The number is not even.");
  20.             System.out.print("Enter even number: ");
  21.  
  22.             try{
  23.                 n= Integer.parseInt(scanner.nextLine());
  24.             }catch (Exception e){
  25.                 System.out.println("Invalid number!");
  26.             }
  27.         }
  28.         System.out.println("Even number entered: "+n);
  29.  
  30.  
  31.     }
  32. }
Advertisement
RAW Paste Data Copied
Advertisement