aspose file tools*
The moose likes Beginning Java and the fly likes I'm lost, need help figuring what todo? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Watch "I New topic
Author

I'm lost, need help figuring what todo?

mike statham
Greenhorn

Joined: Feb 24, 2012
Posts: 16
Been Fix thanks to you all!

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

Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 191

what is the "key" ??


Do not wait to strike till the iron is hot; but make it hot by striking....
Marco Galea
Ranch Hand

Joined: Mar 30, 2011
Posts: 30
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
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 560
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.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7832
    
  21

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  16

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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm lost, need help figuring what todo?