I want to find the average score of a LinkedList. My code is
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bowlinggame;
import java.util.LinkedList;
import java.util.TreeSet;
public class BowlingGame {
public static void main(String[] args)
{
TreeSet <String>PlayerNames = new TreeSet<String>();
PlayerNames.add("Steve");
PlayerNames.add("James");
PlayerNames.add("Bob");
LinkedList <Integer>SteveScore = new LinkedList<Integer>();
SteveScore.add(205);
SteveScore.add(240);//the average of these
SteveScore.add(189);
LinkedList <String>SteveDate = new LinkedList<String>();
SteveDate.add("07/12/2009");
SteveDate.add("08/01/2009");
SteveDate.add("02/27/2010");
LinkedList <Integer>JamesScore = new LinkedList<Integer>();
JamesScore.add(265);
JamesScore.add(220);The average of these
JamesScore.add(280);
LinkedList <String>JamesDate = new LinkedList<String>();
JamesDate.add("05/24/2009");
JamesDate.add("08/07/2009");
JamesDate.add("09/18/2010");
LinkedList <Integer>BobScore = new LinkedList<Integer>();
BobScore.add(205);
BobScore.add(230);// the average of these
BobScore.add(193);
LinkedList <String>BobDate = new LinkedList<String>();
BobDate.add("09/12/2009");
BobDate.add("06/03/2010");
BobDate.add("02/14/2011");
System.out.println("Steve played " + SteveScore.size() + " games and the" + " last score he got was " + SteveScore.getLast() + " and that was on " + SteveDate.getLast());
System.out.println("James played " + JamesScore.size() + " games and the" + " last score he got was " + JamesScore.getLast() + " and that was on " + JamesDate.getLast());
System.out.println("Bob played " + BobScore.size() + " games and the" + " last score he got was " + BobScore.getLast() + " and that was on " + BobDate.getLast());
}
}