Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can some one help me implement these getters method. Thank you constructor: this.professor=professor; this.course=course; Map grades = new HashMap (); ------------------------------------------------------------- public Professor getProfessor() {

Can some one help me implement these getters method. Thank you

constructor:

this.professor=professor; this.course=course; Map grades = new HashMap();

image text in transcribed

-------------------------------------------------------------

public Professor getProfessor() { } public Course getCourse() { } public Map getGrades() { } public void updateGrade (String grade, int numStudents) { } public float getAverage () { }

public int getNumGrade (String grade) { } public int getNumStudents() { }

@Override public int compareTo(CourseGrade o) { }

. Professor getProfessor() that returns the CourseGrade's professor . Course getCourse) that returns the CourseGrade's course . Map getGrades ) that returns the CourseGrade's grades void updat eGrade (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): 4.04.03.73.33.02.72.32.07 1.31.00.7 0.0 0.0Ignore Note that this does not follow the way UMD calculates grades exactly. For example, this project counts a W as a 0, whereas UMD does not include Ws in GPA calculations "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) 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 int getNumGrade (String grade) that returns the number of students who received the given grade Using the example above, calling getNumGrade("A-") should return 3. You can assume that before this method is called, updateGrade will have been called for each grade. int getNumStudents () that returns the total number of students who received a grade (including students who received a grade of "Other") int compareTo(CourseGrade cg). Notice that the CourseGrade class implements Comparable, an interface in Java (https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html) This interface gives classes a way to compare objects using the compareTo method This method should return O if the current CourseGrade object has the same average GPA as the CourseGrade object given as the parameter, 1 if the current CourseGrade's average GPA is greater than the parameter's average GPA, and -1 otherwise. Read this to see how to check if floats are roughly equal. Use 0.000001 as the "epsilon

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions