title: Getting Top Student and calculating average score
body: <p>We are given the Java class Student, class Randomizer, and class Classroom. 
  We were told to fill in the method for getTopStudent and getAverageScore. </p>
  
  <p>Below I have included the classes for Student, Classroom, and ClassroomTester.</p>
  
  <p>The problem: when I run it, the compiler errors.</p>
  
  <p>And I don't get why it's wrong...I did not forget a semicolon and I am not sure what they meant by "illegal start of expression" </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class Student
  {
      private static final int NUM_EXAMS = 4;
      
      private String firstName;
      private String lastName;
      private int gradeLevel;
      private double gpa;
      
      private int[] exams;
      private int numExamsTaken;
  
    
      public Student(String fName, String lName, int grade)
      {
          firstName = fName;
          lastName = lName;
          gradeLevel = grade;
          exams = new int[NUM_EXAMS];
          numExamsTaken = 0;
      }
      
      public double getAverageScore()
      {
          int sum = 0;
          for(int i = 0; i &lt; exams.length;i++)
          {
              sum+=exams[i];
          }
          return (double)sum/numExamsTaken;
      }
      
      public String getName()
      {
          return firstName + " " + lastName;
      }
      
      public void addExamScore(int score)
      {
          exams[numExamsTaken] = score;
          numExamsTaken++;
      }
      
      // This is a setter method to set the GPA for the Student.
      public void setGPA(double theGPA)
      {
          gpa = theGPA;
      }
      
   
      public String toString()
      {
          return firstName + " " + lastName + " is in grade: " + gradeLevel;
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class Classroom
  {
      Student[] students;
      int numStudentsAdded;
      
      public Classroom(int numStudents)
      {
          students = new Student[numStudents];
      
      public Student getTopStudent()
      {
          double max = students[0].getAverageScore();
          String topstudent = students[0].getName();
          for (int i = 0; i &lt; students.length; i++) 
          {
             if (students[i].getAverageScore() &gt; max) 
             {
                 max = students[i].getAverageScore();
                 topstudent = students[i];
             }
          }  
          return topstudent;
      }
      public void addStudent(Student s)
      {
          students[numStudentsAdded] = s;
          numStudentsAdded++;
      }
      
      public void printStudents()
      {
          for(int i = 0; i &lt; numStudentsAdded; i++)
          {
              System.out.println(students[i]);
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class ClassroomTester extends ConsoleProgram
  {
      public void run()
      {
          Classroom c = new Classroom(2);
          
          Student ada = new Student("Ada", "Lovelace", 12);
          ada.addExamScore(44);
          ada.addExamScore(65);
          ada.addExamScore(77);
  
          Student alan = new Student("Alan", "Turing", 11);
          alan.addExamScore(38);
          alan.addExamScore(24);
          alan.addExamScore(31);
  
          // add students to classroom
          c.addStudent(ada);
          c.addStudent(alan);
          c.printStudents();
          
          Student topStudent = c.getTopStudent();
          System.out.println(topStudent);
      }
  }</code></pre>
  </div>
  </div>
  </p>