java – How to parse a text file that is formatted like a gradebook?


I’m trying to read a text file that has data formatted as follows:

Name|Test1|Test2|Test3|Test4|Test5|Test6|Test7|Test8|Test9|Test10   
John Smith|82|89|90|78|89|96|75|88|90|96
Jane Doe|90|92|93|90|89|84|97|91|87|91
Joseph Cruz|68|74|78|81|79|86|80|81|82|87

My goal is to be able to get each student’s average test score, as well as the average score per test (column) and the average score overall. I am having trouble “separating” the first columns (the names of the students) from their test scores. Is there a way to ignore or skip the first column? Also, what is the best way to store those test scores so that I will be able to do those calculations I mentioned?

I have successfully read the contents of the file by using the below method:

in.useDelimiter("\|");
for(int i = 0; in.hasNextLine(); i++){
    System.out.println(in.next());}