/** @param args the command line arguments */ public static void main(String[] args) throws FileNotFoundException { // ask the user for the file name System.out.print("Please enter the name of the file: "); Scanner keyboard = new Scanner(System.in); // create the new file object File newFile = new File(keyboard.nextLine()); // link the file to the new Scanner object Scanner inputFile = new Scanner(newFile); // create a new linked list MyLinkedList myList = new MyLinkedList(); // loop through the file to add each score to the linked list while (inputFile.hasNext()) { // get the next score double x = inputFile.nextDouble(); // create the node and add to the linkedList MyLinkedListNode newNode = new MyLinkedListNode(x); myList.appendNode(newNode); } // loop through the list to find the total MyLinkedListNode p1 = myList.getHead(); double total = 0; int count = 0; while (p1 != null) { total += p1.getNum(); count++; // move along to the next node p1 = p1.getNext(); } System.out.println("/nThe total of all the scores is: " + total); System.out.printf("The average of all the scores is: %.02f %n", total / count); }