Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1)Wirte a class named CourseGrade. The class should have a GradeActivity array n

ID: 3632489 • Letter: 1

Question

1)Wirte a class named CourseGrade. The class should have a GradeActivity array named grades as a field. The arrat should have four elements, one for each of the assignments previously described. The class should have the following methods:

setlab: this method should accept a GradeActivity object as its argument. this object should already hold the student's score for the lab activity. Element 0 of the grades field should reference this object.

setPassFailExam: this method should accept a PassFailExam object as its argument. This object should already hold the student's score for the pass/fail exam. Element 1 of the grades field should reference this object

setEssay: this method should accept an Essay object as its argument. this object should already hold the student's score for the essay. Element 2 of the grades field should reference this object.

setFinalExam: This method should accept a FinalExam object as its argument. This object should already hold the student's score for the final exam. Element 3 of the grades field should reference this object.

to String: this method should return a string that contains the numeric scores and grades for each element in the grades array.

2)Modify the courseGrades class you created so it it implements the following interface:

public interface Analyzable

{

   double getAverage();

   GradedActivity getHighest();

   GradedActivity getLowest();

}

The getAverage method should return the average of the numeric scores stored in the grades array. The getHighest method should return a reference to the element of the grades array that has the highest numeric score. The getLowest method should return a reference to the element of the grades array that has the lowest numeric score. Demonstrate the new methods in a complete program.

Explanation / Answer

class GradedActivity { int labScore; }
class CourseGrades {

GradedActivity[] grades;
public CourseGrades() {
grades = new GradedActivity [4];
}

public void setLab(GradedActivity ga) {
grades[0] = ga;
}
}