Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.stream.Collectors;
- public class map1_Lab_8Academy_Graduation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- Map<String, List<Double>> academy = new TreeMap<>();
- for (int i = 0; i < n; i++) {
- String name = scanner.nextLine();
- List<Double> grade = Arrays.stream(scanner.nextLine().split("\\s+"))
- .map(Double::parseDouble)
- .collect(Collectors.toList());
- academy.putIfAbsent(name, grade);
- }
- for (Map.Entry<String, List<Double>> entry : academy.entrySet()) {
- System.out.printf("%s is graduated with ", entry.getKey());
- double avg = 0;
- for (Double value : entry.getValue()) {
- avg += value;
- }
- System.out.println(avg / entry.getValue().size());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement