vladovip

Find Largest Three Values2 - Java - Alpha Preparation

Jan 15th, 2022
1,019
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Collections;
  5. import java.util.Scanner;
  6.  
  7. public class FindLargestThreeNumbersSecondOption {
  8.     public static void main(String[] args) {
  9.  
  10.         Scanner input = new Scanner(System.in);
  11.         int countNumbersToFollow = Integer.parseInt(input.nextLine());
  12.         Integer[] array = new Integer[countNumbersToFollow];
  13.         for (int i = 0; i < array.length; i++) {
  14.             array[i] = Integer.parseInt(input.nextLine());
  15.         }
  16.         Arrays.sort(array, Collections.reverseOrder());
  17.         System.out.printf("%d, %d and %d", array[0], array[1], array[2]);
  18.     }
  19. }
  20.  
  21.  
RAW Paste Data