Advertisement
vdjalov

Untitled

Aug 12th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.function.Predicate;
  7. import java.util.stream.Stream;
  8.  
  9. public class WeakStudentsZad8 {
  10.  
  11. public static void main(String[] args) throws IOException {
  12.  
  13.  
  14. BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
  15. ArrayList <String> check = new ArrayList<>();
  16.  
  17. while(true){
  18. String input[] = bf.readLine().split("[ ]+");
  19.  
  20. if(input[0].equalsIgnoreCase("end")){
  21. break;
  22. }
  23.  
  24. Stream<String> stream = Arrays.stream(input);
  25. stream .skip(2)
  26. .map(a -> Integer.parseInt(a))
  27. .filter(checkIfMarkIsTwoOrSmaller())
  28. .limit(2)
  29. .forEach(a -> check.add(a.toString()));
  30.  
  31. if(check.size() >= 2){
  32. System.out.println(input[0] + " " + input[1]);
  33. }
  34.  
  35. check.clear();
  36. }
  37. bf.close();
  38. }
  39.  
  40. // The method filters only numbers smaller or equal to 3!
  41. private static Predicate<? super Integer> checkIfMarkIsTwoOrSmaller() {
  42.  
  43. return a -> a <=3 ;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement