Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.function.Predicate;
- import java.util.stream.Stream;
- public class WeakStudentsZad8 {
- public static void main(String[] args) throws IOException {
- BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
- ArrayList <String> check = new ArrayList<>();
- while(true){
- String input[] = bf.readLine().split("[ ]+");
- if(input[0].equalsIgnoreCase("end")){
- break;
- }
- Stream<String> stream = Arrays.stream(input);
- stream .skip(2)
- .map(a -> Integer.parseInt(a))
- .filter(checkIfMarkIsTwoOrSmaller())
- .limit(2)
- .forEach(a -> check.add(a.toString()));
- if(check.size() >= 2){
- System.out.println(input[0] + " " + input[1]);
- }
- check.clear();
- }
- bf.close();
- }
- // The method filters only numbers smaller or equal to 3!
- private static Predicate<? super Integer> checkIfMarkIsTwoOrSmaller() {
- return a -> a <=3 ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement