SHARE
TWEET

min/max/mid

DulcetAirman Jan 6th, 2017 (edited) 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void main(String[] args) {
  2.     final int n = 5;
  3.     try (Scanner s = new Scanner(System.in)) {
  4.         System.out.format("Enter %d numbers:%n", n);
  5.         final int[] a = IntStream.range(0, n).map(i -> s.nextInt()).sorted().toArray();
  6.         System.out.format("Min: %d; Max: %d; Mid: %d%n", a[0], a[n - 1], a[n / 2]);
  7.     }
  8. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top