average of arrays method in java
I have two classes Grade and Course using composition I need to find the average grade in each course. that is my insert and average method where is the error in the last one? I need your help :(. //validation of number of lectures inserted public int insertGrade(Grade g) { for(int i=0; i<grades.length; i++){ if (grades[i] == null) { grades[i] = g; System.out.println("grade added! "); return 0; } System.out.println("you cant add more grades !"); return -1; } //public methods public int courseAverage (Grade g) { int sum=0; for (int i=0; i<grades.length; i++) { sum = sum + Grade[i]; } return sum / grades.length; }