Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SetsAndMaps;
- import java.util.Arrays;
- import java.util.Map;
- import java.util.Scanner;
- import java.util.TreeMap;
- public class AcademyGraduation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int number = Integer.parseInt(scanner.nextLine());
- Map<String, Double> students = new TreeMap<>();
- for (int index = 0; index < number; index++) {
- String studentName = scanner.nextLine();
- double[] scores = Arrays
- .stream(scanner.nextLine().split("\\s+"))
- .mapToDouble(Double::parseDouble)
- .toArray();
- double averageScore = 0.0;
- for (double score : scores) {
- averageScore += score;
- }
- averageScore /= scores.length;
- students.putIfAbsent(studentName,averageScore);
- }
- students.forEach((key, value) -> {
- System.out.printf("%s is graduated with " + value + "%n", key);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment