public static void main(String[] args) throws Exception
{
File fileToRead = new File("scores.txt");
Scanner input = new Scanner(fileToRead);
final int NUM_STUDENTS = 16;
String studentName;
double labScores = 0;
double quizScores, projectScores, examScores, finalScore;
while (input.hasNext())
{
studentName = input.nextLine();
for (int i = 0; i < 15; ++ i)
{
labScores = input.nextDouble();
}
System.out.println(labScores);
}
hello, i am having some trouble reading some numbers from a file.
The file is set up in the below format. I need to read the lab scores (2nd line) and do an average of them. I am trying to use a for loop to do this, but it is not working and I am really confused. All I would like to do right now is figure out how to read in the whole line of lab scores, but as individual doubles. I don't know if this makes sense or not, but I would appreaciate any help!
Puckett, Karen
10 10 9.5 10 10 8 9.5 10 10 10 9 10 10 10 0
4 3 5 3 5 2 3 2 1.5 1 5 3.5
17.5 24 22 23.5 22 23
90 91
96
Little, Charles
10 10 9 10 10 4 9 10 0 10 10 10 10 10 10
2 5 3 2.5 1 4 0 4 5 4 3.5 5
22 7 19.5 23 24 20.5
78 56
53... and so on
This post has been edited by illjay7005: 08 November 2009 - 12:18 PM

New Topic/Question
Reply




MultiQuote



|