Can you guys solve this for me : JAVA Classroom Grades Analyser


#21

Here is my updated version…

import java.util.ArrayList;
class GradeAnalyser{
public GradeAnalyser(){
}

public int getAverage(ArrayList grades){

if(grades.size()<1){
System.out.println(“The ArrayList is empty.”);
return 0;
}else{
int sum=0;

for(Integer grade:grades){
  
  sum=sum+grade;
}

int average= sum/grades.size();
System.out.println(average);
return average;
}
}
public static void main(String[] args){
ArrayList myClassroom=new ArrayList();
myClassroom.add(98);
myClassroom.add(92);
myClassroom.add(88);
myClassroom.add(75);
myClassroom.add(61);
myClassroom.add(89);
myClassroom.add(95);
GradeAnalyser myAnalyser=new GradeAnalyser();
myAnalyser.getAverage(myClassroom);
System.out.println(myClassroom.get(0));
System.out.println(myClassroom.get(6));

}
}

and I got an error:
Error: Could not find or load main class GradeAnalyzer


#22

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.