vladovip

Find Largest Three Values - Java

Jan 15th, 2022
711
362 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.lang.invoke.SwitchPoint;
  4. import java.util.Scanner;
  5.  
  6. public class FindLargestThreeValues {
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         int countNumbersToFollow = Integer.parseInt(input.nextLine());
  10.  
  11.         int num1 = 0;
  12.         int num2 = 0;
  13.         int num3 = 0;
  14.         String inputNumbers = "";
  15.         for (int i = 1; i <= countNumbersToFollow; i++) {
  16.          inputNumbers += input.nextInt() + " ";
  17.         }
  18.  
  19.         System.out.println(inputNumbers);
  20.  
  21.  
  22.     /*
  23.         Math Max method option 1:
  24.         int largestInt = Math.max(num1, Math.max(num2, num3));
  25.  
  26.         OR second option:
  27.         double largestOfnum1num2 = num1 > num2 ? num1 : num2;
  28.         int largestInt = largestOfnum1num2 > num3 ? largestOfnum1num2 : num3;
  29.         System.out.println(number);
  30.   */
  31.  
  32.     }
  33. }
  34.  
  35.  
  36. /* Task description:  ????? to find  three largest numbers in a sequence and prints them in descending order in the following format:
  37.             {largest}, {second_largest} and {third_largest}. */
RAW Paste Data