Q:

Java how to compute average scores using loops

I need to write a program in Java that computes the average score for 4 students. The student will put in their 4 scores, and once they are done they will input -1 to compute the average. Once this is done the program needs to move onto student 2 and so on. At the end it is supposed to display the highest average from the 4 student average test scores. Here is what it should look like when it is run:
Student 1
Enter your score: 100
Enter your score: 90
Enter your score: 80
Enter your score: 70
Enter your score: -1 * once the student enters -1 it should compute average
Average Score = 85.
Student 2
Enter your score: 90
ETC
ETC
The problem with my code is that the average is only correct for the first student. When I input -1 to get the average for the second student, the calculation is incorrect. We are only allowed to use loops. The only hints I was given were that we are supposed to write an outer loop that iterates 4 times, write an inner loop that loops as long as the student has scores to enter, inside the inner loop prompt the user to enter their last score or -1 to compute average. I don't want you guys to do the project for me but to just set me in the right direction. I feel like I am not using the right loop.
import java.util.Scanner;

public class TestScore

{

     public static void main(String[]args)
     {

       double score = 0;

       double totalScore = 0;

       double count = 0;

       double average = 0;

       Scanner input = new Scanner(System.in);

      System.out.println("Student 1");
      System.out.printf("Enter Your Score: ");
      score = input.nextDouble();

      while (score != -1){
          System.out.printf("Enter Your Score: ");
          totalScore = totalScore + score;
          score = input.nextDouble();
          count++;
          average = totalScore / count;

          if (score == -1){
              System.out.printf("Average Score = %.2f\n ",average);
              count = 0;
              score = 0;
              totalScore = 0;
              average = 0;
              System.out.println("Student 2");
              System.out.printf("Enter Your Score: ");
              score = input.nextDouble ();
              count++;
              average = totalScore / count;
          }   

      }  

}

}

A:

You haven't explicitly asked a question so I'll try and comply to the "set me in the right direction" part.
I'd suggest re-formatting the loop structure to a cleaner one, like this:
double total;
for(int student = 1; student <= 4; student++) {
    System.out.printf("Student %d\n", student);
    double sum = 0, count = 0;

    while(true) {
        System.out.printf("Enter your score: ");
        double input = scanner.nextDouble();
        if(input == -1) break;
        sum += input;
        count++;
    }
    total += sum;

    System.out.printf("Average: %.2f\n", sum / count);
}

System.out.printf("Total: %.2f\n", total);

Hope that's enough to give you some pointers.
edit: forgot to take care of total

