-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCourses.java
31 lines (25 loc) · 866 Bytes
/
Courses.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class Courses {
// Map of course names and marks
private Map<String, Double> courseMarks;
public Courses(Map<String, Double> courseMarks) {
this.courseMarks = new HashMap<>(courseMarks);
}
// Return the average marks in the given courses
public double averageSomeCourses(Set<String> courseNames) {
// Complete this method
return 0;
}
public void print() {
System.out.print("Courses: ");
for (Map.Entry<String, Double> entry : courseMarks.entrySet()) {
System.out.printf("%s: %.2f, ", entry.getKey(), entry.getValue());
}
System.out.println("");
}
}