Demonstrate the class in a simple program 5. Course Grades In a course, a teache
ID: 3873736 • Letter: D
Question
Demonstrate the class in a simple program 5. Course Grades In a course, a teacher gives the following tests and assignments: A lab activity that is observed by the teacher and assigned a numeric score. . A pass/fail exam that has 10 questions. The minimum passing score is 70 An essay that is assigned a numeric score. A final exam that has 50 questions. Write a class named courseGzades. The class should have a GeadedAetivity array named gzadeal as a field. The array should have four elements, one for each of the assignments previously described. The class should have the following methods: This method should accept a Gradedhctivity 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 setLab: setPansTailExam: This method should accept a Passailxam object as its argument. This object should already hold the student's score for the pass/fail exam. Element 1 of the gradea field should reference this object. This method should accept an Essay object as its argument. (See Programming Challenge 4 for the essay class. If you have not completed Programming Challenge 4, use a dradedkotivity object instead.) This object should already hold the student's score for the essay. Element 2 of the iraa field should reference this object. setEssay setPinalEx This method should accept a rinalExam 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 ostring This method should return a string that contains the numeric scores and gads for each element in the lii array. Demonstrate the class in a program.Explanation / Answer
public class CourseGrades {
private GradedActivity grades[] = new GradedActivity[4];
void setLab(GradedActivity activity) {
grades[0] = activity;
}
void setPassFailExam(PassFailExam exam1) {
grades[1] = exam1;
}
void setEssay(GradedActivity activity) {
grades[2] = activity;
}
void setFinalExam(FinalExam exam1) {
grades[3] = exam1;
}
public String toString() {
return " Lab Activity " + grades[0].toString()
+ " Pass Fail Examination " + grades[1].toString() + " Essay "
+ grades[2].toString() + " final Examination "
+ grades[3].toString();
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.