• Post Reply Bookmark Topic Watch Topic
  • New Topic

Prompt the user for a file name. Scan the file (use data_store.next()) to determine the most common  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have my code working up to where it reads and opens the file. I know that I need to have it read the lines of text and save it into a map and my teacher also wants me to use the data_store.next(). I am stuck. Can someone please help me figure out how to keep going on this?
My code so far:


or if anyone has better ideas on how i should code this still using a map i would really appreciate it. It is due by 11:55pm and I am stuck. Thank you
 
Saloon Keeper
Posts: 3336
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "most common" what? And, where did "data_store.next()" come from? I'm not familiar with that one.
 
Sammie Hassett
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
most common word longer than 5 characters sorry, and Im not sure myself..We coded something using a data_store, but im not sure if its what i need because i do not know how to implement it in this new code. I will attach that code here

this was an in class example
 
Sheriff
Posts: 11496
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Scanner class has a next() method that reads in the next complete token. "use data_store.next()" probably assumes that you named the scanner variable "data_store" instead of "in".

Edit: Sorry, need to clarify that. The Scanner class can also take a File as its source. So rather than use a FileReader, I assume you're expected to use a Scanner that is taking its input from a File. Hence, the instruction to "scan the file ..." and the variable you assign the scanner instance to is assumed to be "data_store". You will still use the Scanner referenced by the "in" variable to get user input. You can have multiple Scanner instances in your program, with each instance getting input from different sources. In your case, the "in" scanner would get input from the console and the "data_store" scanner will get input from the file specified by the user.

A map has keys and values. Now, if you were to determine the most common words, what would "most common" mean? How would you track the "most common" words by using a map? What would be your key and what would be the corresponding value for each key?
 
Sammie Hassett
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your explanation that helped me to finish the code
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!