Question: help me with this class instructions: The CourseGrade class connects a Professor and a Course with grades. It must have the following: Instance variables: Professor
help me with this class
instructions: The CourseGrade class connects a Professor and a Course with grades. It must have the following: Instance variables:
Professor professor, representing the CourseGrades professor
Course course, representing the CourseGrades course
Map grades, which maps a grade to the number of students who received that grade. The key is a String, rather than a char, because there are grades such as A+ and Other (explained below) that are more than one character. Constructors:
2 A constructor that takes a Professor and Course and sets each instance variable to the respective parameter. It should also initialize grades to a new, empty HashMap. Methods:
Professor getProfessor() that returns the CourseGrades professor
Course getCourse() that returns the CourseGrades course
Map getGrades() that returns the CourseGrades grades
void updateGrade(String grade, int numStudents) that sets grades for the key grade to numStudents. It should overwrite any previously stored grade.
float getAverage() that returns the average GPA for CourseGrade. A grade can be converted to a GPA using this table (found here): A+ A A- B+ B B- C+ C C- D+ D D- F W Other 4.0 4.0 3.7 3.3 3.0 2.7 2.3 2.0 1.7 1.3 1.0 0.7 0.0 0.0 Ignore .Other grades are grades which were not reported for some reason. They should be ignored. For example, a course with 3 students who received an A-, 1 who received a C, 1 who received a W, and 1 who received an Other will have an average GPA of 2.62: (3 ? 3.7) + (1 ? 2.0) + (1 ? 0.0) (3 + 1 + 1) = 2.62 We divide by 5, not 6, because we do not include the Other grade in the average calculation. Note that you do not need to round; just return what you calculated.
-------------------------------------------------------------------------------------------------------
class
public class CourseGrade implements Comparable
private Professor professor;
private Course course;
private Map
public CourseGrade (Professor professor, Course course) {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public Professor getProfessor() {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public Course getCourse() {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public Map
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public void updateGrade (String grade, int numStudents) {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public float getAverage () {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public int getNumGrade (String grade) {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
public int getNumStudents() {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
@Override
public int compareTo(CourseGrade o) {
throw new UnsupportedOperationException("Remove this line and replace with your implementation.");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
