[Logo]
Forums Register Login
I'm lost, need help figuring what todo?
Been Fix thanks to you all!

Reposed the old code, after I learn I shouldn, sry agian

what is the "key" ??
you haven't declared "key" anywhere in your code that's why it's throwing that error. If you want to read the nextDouble you should use the reference you created for the Scanner object i.e. "scan"



also i don't actually get the use of the do-while in the first place. i think you could have done for example



but you'll still will have a problem cause you need to advance the scanner to the next new line and calculate the average for each "person" and print
You may want to scan each whole line from the file as a single String object, split() the line into an array of String objects at the " " (space), then parse the resulting String objects into the desired forms ( String, Double, Double, Double ). Repeat while lines exist in the file.

This approach works well if you're then creating objects from the data, say a Student object, in which to store the results.
 

Greg Brannon wrote:You may want to scan each whole line from the file as a single String object, split() the line into an array of String objects at the " " (space), then parse the resulting String objects into the desired forms ( String, Double, Double, Double ).


Totally agree. I dislike Scanner intensely.

Winston
Sorry for hijacking, but how come? I think Scanner is a wonderful class.
 

Stephan van Hulst wrote:Sorry for hijacking, but how come? I think Scanner is a wonderful class.



I've just never liked the color scheme.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 743 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 18, 2018 15:11:20.