Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.*;
- public class AcademyGraduation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Map<String, Double[]> students = new TreeMap<>();
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- String name = scanner.nextLine();
- String[] arr = scanner.nextLine().split("\\s+");
- Double[] scores = new Double[arr.length];
- for (int j = 0; j < arr.length; j++) {
- scores[j] = Double.parseDouble(arr[j]);
- }
- students.put(name, scores);
- }
- students.forEach((k, v) -> {
- System.out.print(k + " is graduated with ");
- double sum = 0;
- for (Double aDouble : v) {
- sum += aDouble;
- }
- double average = sum / v.length;
- DecimalFormat floatPoint;
- floatPoint = new DecimalFormat("#.###############");
- System.out.println(floatPoint.format(average));
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement