020-005-002

Comprehensive Collections: Grade Management System

Hard

Problem Description

Combining Collections

In this problem, you will create a program that manages name-score data using a combination of Map and TreeSet, performs aggregation with the Stream API, and displays the result to standard output.

Data Structure Selection

// Map for name-score association
Map<String, Integer> scores = new HashMap<>();
// TreeSet for top scorers (auto-sorted)
TreeSet<String> topScorers = new TreeSet<>();

Learning Points

  • Map: Maintains key-value associations
  • TreeSet: Automatically keeps elements sorted
  • Stream API: Can write aggregations concisely
  • Proper data structure selection leads to efficient code

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
4
Alice 85
Bob 92
Charlie 78
Diana 92
Expected Output:
Average: 86
Top: Bob
Above average: 2
Boundary case
Input:
3
Eve 100
Frank 100
Grace 100
Expected Output:
Average: 100
Top: Eve
Above average: 0

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining