import java.io.*; public class SinglyMain { public static void main (String [ ] args) { final String SENTINEL = "***"; final String PROMPT = "Please enter a GPA (or " + SENTINEL + " to quit): "; final String AVERAGE_MESSAGE = "\n\nThe average GPA is "; SinglyLinkedList gpaList = new SinglyLinkedList(); BufferedReader reader = new BufferedReader ( (new InputStreamReader (System.in))); String line; while (true) { try { System.out.println (PROMPT); line = reader.readLine (); if (line.equals (SENTINEL)) break; gpaList.add (new Double (line)); } // try catch (IOException e) { System.out.println (e); } // catch } // while double sum = 0.0; for (Double d : gpaList) sum += d; System.out.println (AVERAGE_MESSAGE + (sum / gpaList.size ())); } // method main } // class SinglyMain