• Post Reply Bookmark Topic Watch Topic
  • New Topic

File processing baby names  RSS feed

 
Hope Olivianna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I'm working on an assignment for my java class and I need ideas on how to move on.
I have to use file processing to make a line graph on the popularity of names over a period of time.
I think I have managed to get all the other methods down except the one that scans the txt file to get the results on the graph.


The assignment specs are here http://courses.cs.washington.edu/courses/cse142/13su/homework/6/spec.html
I've tried to use my textbook for reference and it's not helping very much.
Thank you for your time.
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the requirement here? You search for a name and gender and if found, you plot a graph based on the available input in the data file corresponding to that name and gender?
 
Hope Olivianna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly it.
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I guess the above has a complete line from file. The very first thing what you should do is, split it get name, gender and other details. Once you get name and gender compare it with the user input, and if matched you have the data to plot the graph.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:I guess the above has a complete line from file. . . .
No, it reads from whever you left off reading to the end of the line. It only reads the whole line if
  • Nothing else has been read before with that Scanner, or
  • The last call to that Scanner was for nextLine()
  • More details in this post.
     
    Swastik Dey
    Rancher
    Posts: 1815
    15
    Android Eclipse IDE Java Java ME
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    (
    Campbell Ritchie wrote:
    Swastik Dey wrote:I guess the above has a complete line from file. . . .
    No, it reads from whever you left off reading to the end of the line. It only reads the whole line if
  • Nothing else has been read before with that Scanner, or
  • The last call to that Scanner was for nextLine()
  • More details in this post.


    By complete line what I wanted to say is read complete line (i.e one line complete line).
     
    Campbell Ritchie
    Marshal
    Posts: 56570
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    But you do not get a complete line if you use nextLine after nextSomethingDifferent. As I said, either use nextLine throughout or you have to use it twice.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!