dtalley11

example.java

Jul 2nd, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class example {
  4.  
  5.     public static void main(String[] args) {
  6.         try {
  7.             int x = Integer.parseInt(args[0]);
  8.             int y = Integer.parseInt(args[1]);
  9.             if (x==y && x >25) {
  10.                 System.out.println("x is large, and so is y");
  11.             }
  12.             else if (x != y) {
  13.                 System.out.println("x is not equal to y");
  14.             }
  15.             else if (x > 15){
  16.                 System.out.println("x still somewhat large");
  17.             }
  18.             else if  (x >= 1) {
  19.                 System.out.println("x positive at least");
  20.             }
  21.             else if (x == 0) {
  22.                 System.out.println("x is 0");
  23.             }
  24.             else if (x < 0) {
  25.                 System.out.println("x is negitive");
  26.             }
  27.             else {
  28.                 System.out.println("x is not a number");
  29.             }
  30.         }
  31.         catch (NumberFormatException|ArrayIndexOutOfBoundsException e){
  32.             System.out.println("\r\nX and Y are not Integers\r\nto run this program:\r\njava example x y");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment