deyanmalinov

05 Min Even Number

Apr 21st, 2020
349
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DPM;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Optional;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         Scanner scan = new Scanner(System.in);
  10.         Optional<Double> nums = Arrays.stream(scan.nextLine().split(" "))
  11.                 .filter(num -> !num.isEmpty())
  12.                 .map(Double::valueOf)
  13.                 .filter(num -> num % 2 == 0)
  14.                 .min(Double::compare);
  15. ----------------------------------------------------------------
  16.         OptionalDouble nums = Arrays.stream(scan.nextLine().split(" "))
  17.                 .filter(num -> !num.isEmpty())
  18.                 .mapToDouble(Double::parseDouble)
  19.                 .filter(num -> num % 2 == 0)
  20.                 .min();
  21. -----------------------------------------------------------------
  22.         if (nums.isPresent()){
  23.             System.out.printf("%.2f",nums.get()); //nums.getAsDouble();
  24.         }else {
  25.             System.out.println("No match");
  26.         }
  27.     }
  28. }
RAW Paste Data