5. Course Grades In a course, a teacher gives the following tests and assignment
ID: 3767953 • Letter: 5
Question
5. Course Grades In a course, a teacher gives the following tests and assignments: e 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 courseGrades. The class should have a GradedActivity array named grades as a field. The array 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 GradedActivity object as its argu- ment. This object should already hold the student's score for the lab activity. Element 0 of the grades field should reference this object. This method should accept a PassFailExam object as its argu- ment. This object should already hold the student's score for the pass/fail exam. Element 1 of the grades field should reference this object. This method should accept an Bssay object as its argument. (See Programming Challenge 4 for the Essay class. If you have not completed Programming Challenge 4, use a GradedActivity object instead.) This object should already hold the student's score for the essay. Element 2 of the grades field should reference this object. 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. This method should return a string that contains the numeric scores and grades for each element in the grades array. setPassFailExam: setEssay: setFinalExam: tostring: Demonstrate the class in a program.Explanation / Answer
import java.util.Scanner; 02 03 public class CourseGrades { 04 05 06 public static void main(String[] args){ 07 08 int grades,FinalExam,essay,PassFailExam,GradedActivity; 09 10 // Create an array of GradedActivity references. 11 12 13 GradedActivity.grades[],[] = new int grades.grades[4]; 14 15 // The first grades is a regular exam with a 16 // numeric score of 95. 17 grades[0] = new grades(); 18 grades[0].setLab(95); 19 20 // The second grade is a pass/fail test. The 21 // student missed 3 out of 10 questions, and the 22 // minimum passing grade is 70. 23 grades[1] = new PassFailExam(10, 3, 70); 24 25 // The third grade is an essay with an 26 //assigned numeric score 27 grades[2] = new grades(); 28 grades[2].essay(95); 29 30 31 // The fourth grade is the final exam. 32 // There were 50 questions. 33 grades[3] = new FinalExam(50); 34 35 // Display the grades. 36 for (int index = 0; index = 90) 76 letterGrade = 'A'; 77 else if (score >= 80) 78 letterGrade = 'B'; 79 else if (score >= 70) 80 letterGrade = 'C'; 81 else if (score >= 60) 82 letterGrade = 'D'; 83 else letterGrade = 'F'; 84 85 return letterGrade; 86 } 87 } 88 } 89 }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.