The text file should be formatted as follows:
Barry Burd ,101 Harriet Ritter ,200 Weelie J. Katz ,030 Harry "The Crazyman" Spoonswagler ,124 Filicia "Fishy" Katz ,075 Mia, Just "Mia" ,111 Jeremy Flooflong Jones ,102 IM D'Arthur ,001 Hugh R. DaReader ,212
So the problem was that a double was represented as x.xxx instead of x,xxx , which caused an exception!
This solves the current exception, but with the same code you get one more error: Exception in thread "main" java.util.NoSuchElementException: No line found
Take a look at the for loop:
for (int num = 1; num <= 9; num++) { player = new Player(hankeesData.nextLine(), hankeesData.nextDouble()); hankeesData.nextLine();
When repeating the last time (i.e. num = 9 ) we read the name of the player, then we read it on average. But then again we are hankeesData.nextLine(); ! However, the mean was the last line in this text file, and there is nothing more to read, so doing hankeesData.nextLine(); one last time will result in a No line found exception.
for (int num = 1; num <= 9; num++) { player = new Player(hankeesData.nextLine(), hankeesData.nextDouble()); if (hankeesData.hasNextLine()) hankeesData.nextLine();
source share