The problem with the codes it that, in "getAverage" it is not allowing the "return null". I assume this is because it is declared a double. What is the proper way to return the "getAverage"?
public class StudentScores { private ArrayList<Student> scores; public StudentScores() { scores = new ArrayList<Student>(); } public void add(String name, int score) { scores.add(new Student(name, score)); } public Student getHighest() { if (scores.size() == 0) return null; Student highest = scores.get(0); for (int i = 1; i < scores.size(); i++) if (scores.get(i).getScore() > highest.getScore()) highest = scores.get(i); return highest; } public Student getLowest() { if (scores.size() == 0) return null; Student lowest = scores.get(0); for (int i = 1; i < scores.size(); i++) if (scores.get(i).getScore() < lowest.getScore()) lowest = scores.get(i); return lowest; } public double getAverage() { if (scores.size() == 0) return null; //will not return, BlueJ gives error of "incompatible types" Student lowest = scores.get(0); for (int i = 1; i < scores.size(); i++) if (scores.get(i).getScore() < lowest.getScore()) lowest = scores.get(i); return lowest; } }