0

For my java class in college, I need to read a text file that holds the scores of a golf game and add them together to reach a total. I can scan the first column of the file fine, but I cannot figure out how to read the integers in the second, third, etc. column(s).

Here is the pertinent Method:

public static int Total(int passed, String fileName) throws IOException   {

    int total = 0;
    Scanner fileScan = new Scanner(new File(fileName));

    for (int line = 1; line <= 18; line++)   {
        for(int col = passed; col == passed; col++)   {
            total += fileScan.nextInt();
        }
    }

    return total;
}   //End of Total Method
gangwerz
  • 435
  • 2
  • 8
  • 18
  • 1
    Refer to : http://stackoverflow.com/questions/9084040/reading-selective-column-data-from-a-text-file-into-a-list-in-java – Praneeth Puligundla Nov 23 '14 at 00:52
  • Thanks to Nani2015's comment, I learned that this was answered [here][1] [1]: http://stackoverflow.com/questions/9084040/reading-selective-column-data-from-a-text-file-into-a-list-in-java – gangwerz Jun 10 '15 at 20:57

0 Answers0