brainfrz

Untitled

Oct 11th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. //newest
  2. public static void main( String[] args ) {
  3.     Scanner user_input = new Scanner(System.in);
  4.     long radicand = 0;
  5.     long[] rads;
  6.     boolean isNegative = false, consoleInput = false;
  7.  
  8.     try {
  9.         radicand = Long.parseLong(args[0]);
  10.         consoleInput = true;
  11.     }
  12.     catch (ArrayIndexOutOfBoundsException e) { }
  13.     catch (NumberFormatException e2) {
  14.         System.out.print("That wasn't an integer. ");
  15.     }
  16.  
  17.  
  18.     if (consoleInput == false) {
  19.         radicand = Prompt.integer("Please enter the current radicand");
  20.     }
  21.  
  22.     if (radicand < 0) {
  23.         radicand = -radicand;
  24.         isNegative = true;
  25.     }
  26.  
  27.  
  28.     rads = simplify(radicand);
  29.     System.out.println(display(radicand, rads[0], rads[1], isNegative));
  30. }
  31.  
  32. //new
  33. public static void main( String[] args ) {
  34.     Scanner user_input = new Scanner(System.in);
  35.     long radicand = INPUT_FAILURE;
  36.     long[] rads;
  37.     boolean isNegative = false;
  38.  
  39.     try {
  40.         radicand = Long.parseLong(args[0]);
  41.     }
  42.     catch (ArrayIndexOutOfBoundsException e) { }
  43.     catch (NumberFormatException e2) {
  44.         System.out.print("That wasn't an integer. ");
  45.     }
  46.  
  47.  
  48.     while (radicand == INPUT_FAILURE) {
  49.         radicand = Prompt.integer("Please enter the current radicand");
  50.     }
  51.  
  52.     if (radicand < 0) {
  53.         radicand = -radicand;
  54.         isNegative = true;
  55.     }
  56.  
  57.  
  58.     rads = simplify(radicand);
  59.     System.out.println(display(radicand, rads[0], rads[1], isNegative));
  60. }
  61.  
  62. //old
  63. public static void main( String[] args ) {
  64.     Scanner user_input = new Scanner(System.in);
  65.     long radicand = INPUT_FAILURE;
  66.     long[] rads;
  67.     boolean isNegative = false;
  68.  
  69.     try {
  70.         radicand = Long.parseLong(args[0]);
  71.     }
  72.     catch (ArrayIndexOutOfBoundsException e) { }
  73.     catch (NumberFormatException e2) {
  74.         System.out.print("That wasn't an integer. ");
  75.     }
  76.  
  77.  
  78.     while (radicand < 0) {
  79.         System.out.print("Please enter the current radicand: ");
  80.  
  81.         try {
  82.             radicand = Long.parseLong(user_input.next());
  83.         }
  84.         catch (NumberFormatException e) {
  85.             System.out.print("That's not an integer! ");
  86.             radicand = INPUT_FAILURE;
  87.             continue;
  88.         }
  89.        
  90.         if (radicand < 0) {
  91.             radicand = -radicand;
  92.             isNegative = true;
  93.         }
  94.     }
  95.  
  96.  
  97.     rads = simplify(radicand);
  98.     System.out.println(display(radicand, rads[0], rads[1], isNegative));
  99. }
Advertisement
Add Comment
Please, Sign In to add comment