this line: int average = sum / size.grades();
produces the following error:
GradeAnalyzer.java:20: error: cannot find symbol
int average = sum / size.grades();
^
symbol: variable size
location: class GradeAnalyzer
1 error
Although it is exactly written like that in the walk through video!
What is the problem!?
import java.util.ArrayList;
public class GradeAnalyzer{
public GradeAnalyzer(){
}
public int getAverage(ArrayList<Integer> grades){
if(grades.size() < 1){
System.out.println("Sorry, the array list is empty! ");
return 0;
}
else{
int sum = 0;
for(int grade : grades){
sum += grade;
}
int average = sum / size.grades();
System.out.println(average);
return average;
}
}
public static void main(String[] args) {
ArrayList<Integer> myClassroom = new ArrayList<Integer>();
myClassroom.add(98);
myClassroom.add(92);
myClassroom.add(88);
myClassroom.add(75);
myClassroom.add(61);
myClassroom.add(89);
myClassroom.add(95);
GradeAnalyzer myAnalyzer = new GradeAnalyzer();
myAnalyzer.getAverage(myClassroom);
}
}