[Solved] Build a list of the names of students currently enrolled in a number of units strictly greater than the unitThreshold


If I’m understanding you correctly, you’re supposed to get a list of students who are enrolled in >= unitThreshold number of units? If so, this should help:

 for (String studentName : courseListsByStudentName.keySet()) {
     int units = 0;
     List<Course> courses = courseListsByStudentName.get(studentName);
     for (Course course : courses) {
         units += course.getNumUnits();
     }
     if (units > unitThreshold) {
         overEnrolledStudents.add(studentName);
     }
 }

5

solved Build a list of the names of students currently enrolled in a number of units strictly greater than the unitThreshold