DulcetAirman

min/max/mid

Jan 6th, 2017
314
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.31 KB | None | 0 0
  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. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment