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

can someone please help why my output looks like this for the highest and the lo

ID: 3687997 • Letter: C

Question

can someone please help why my output looks like this for the highest and the lowest Average Score: 82.50 the highest: GradedActivity@3e2f1b1a The Lowest: Essay@69c67db here is my CourseGrades code: public class CourseGrades implements Analyzable { private GradedActivity[] grades = new GradedActivity [4]; public void setLab(GradedActivity ga) { grades[0] =ga; } public void setPassFailExam(PassFailExam aPassFailExam) { grades[1] = aPassFailExam; } public void setEssay(Essay anEssay) { grades[2] = anEssay; } public void setFinalExam(FinalExam aFinalExam) { grades[3] = aFinalExam; } public String toString() { return "Lab Score: " + grades[0].getScore() + " Grade: " + grades[0].getGrade () + " Pass/Fail Exam Score: " + grades[1].getScore() + " Grade: " + grades[1].getGrade() + " Essay Score: " + grades[2].getScore() + " Grade: " + grades[2].getGrade() + " Final Exam Score: " + grades[3].getScore() + " Grade: " + grades[3].getGrade(); } /*the following getAverage method computes and returns the average score of all elemnts in the grades array. */ // getAverage method implementation public double getAverage () { double total = 0 ; for (int i = 0; i < grades.length ; i++) { total += grades [i].getScore (); } double average = total/grades.length; return average; } /*the follwoing getHighest methods finds a returns the reference to the element with the highest score in the grades array. */ //getHighest method implementation public GradedActivity getHighest () { GradedActivity highest = grades [0]; for (int i = 0; i < grades.length; i++) { if (grades[i].getScore() > highest.getScore()) highest = grades [i]; } return highest; } public GradedActivity getLowest () { GradedActivity lowest= grades [0]; for (int i = 0; i < grades.length; i++) { if (grades[i].getScore()

Explanation / Answer

The code is not fully understandasbale and is incomplete.

Anyways with the provided code, I could guess there is an error with theHighest code. Please modify your code as below and let me know

public GradedActivity getHighest()
   {
       GradedActivity highest = grades[0];
      
       for(GradedActivity current : grades)
       {
           if(current.getScore() > highest.getScore())
           {
               highest = current;
           }
       }
      
       return highest;
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote