import java.io.*;
 
// a class created to store one int, plus the link
class Score
{
  int value;
  Score next; // the link
} // Score

public class IntLinkedList
{
  public static void main(String[] argv) throws Exception
  {
    BufferedReader cin;
    cin = new BufferedReader(new InputStreamReader(System.in));
 
    // create an empty linked list
    Score start = null;
 
    // read and save the records
    while (true)
    {
      // create a node and read its data fields
      Score aScore = new Score();
      System.out.print("Enter a score [-1 to quit]: ");
      aScore.value = new Double(cin.readLine()).intValue();

      // check for sentinel value
      if (aScore.value == -1) break;

      // add node to front of list
      aScore.next = start;
      start = aScore;
    } // while

    // traverse the list and get the average
    int count = 0; // to count the number of nodes in the list
    int sum = 0; // to accumulate the total of all scores
    Score p;
    for (p = start; p != null; p = p.next)
    {
      sum += p.value;
      count++;
    }

    // print the result
    if (count > 0)
    {
      float average = (float)sum / count;
      System.out.print("The average of " + count + " scores is " + average);
    }
    else
      System.out.println("No values were entered.");
  } // main
} // public class
