Advertisement
Bpoleonjr

max1020

Jan 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. //  Description
  2. //      Given 2 positive int values, return the larger value that is in the
  3. //      range 10..20 inclusive, or return 0 if neither is in that range.
  4. //
  5. //      Example - max1020(a,b)
  6. //      max1020(11, 19) → 19
  7. //      max1020(19, 11) → 19
  8. //      max1020(11, 9) → 11
  9.  
  10.  
  11. public class max1020 {
  12.     public static void main(String []args) {
  13.         int a, b;
  14.         a = Integer.parseInt(args[0]);
  15.         b = Integer.parseInt(args[1]);
  16.        
  17.         if ((a >= 10 && a <=20) || (b >= 10 && b <=20)) {
  18.             if (a <= 20 && a > b) {
  19.                 System.out.println(a);
  20.             } else {
  21.                 System.out.println(b);
  22.             }
  23.         } else {
  24.             System.out.println("0");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement