943,186 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 390
  • Java RSS
Apr 10th, 2010
0

Java Help

Expand Post »
im trying to take an inputed file and use a linked list to read it and display the most frequently used word. Anybody know how to do it?

Java Syntax (Toggle Plain Text)
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.util.*;
  5. public class mostFrequentWord
  6. {
  7. LinkedList<Word> list = new LinkedList<Word>();
  8. public void Read()
  9. throws FileNotFoundException
  10. {
  11. Scanner input = new Scanner(System.in);
  12. FileReader reader = new FileReader("test.txt");
  13. Scanner in = new Scanner(reader);
  14. in.useDelimiter(" [ ^ a - zA - Z ] + ");
  15. while (in.hasNext())
  16. {
  17. String s = in.next().toLowerCase();
  18. System.out.println(s);
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25. }
  26. }
Java Syntax (Toggle Plain Text)
  1. import java.util.LinkedList;
  2.  
  3. public class Word
  4. {
  5. private String toWord;
  6. private int Count;
  7.  
  8. public void assign(int count, String word)
  9. {
  10. toWord = word;
  11. Count = count;
  12. }
  13. public void isEqual()
  14. {
  15. LinkedList<Word> list = new LinkedList<Word>();
  16.  
  17. String x = "?";
  18. String x2 = "?";
  19. if (x.equals(x2))
  20. {
  21. System.out.println("?");
  22. }
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. }
Java Syntax (Toggle Plain Text)
  1. import java.io.FileNotFoundException;
  2.  
  3. public class testmostFrequentWord
  4. {
  5. public static void main(String[] args)
  6. throws FileNotFoundException
  7. {
  8. mostFrequentWord m = new mostFrequentWord();
  9. Word w = new Word();
  10. m.Read();
  11. w.isEqual();
  12.  
  13. }
  14.  
  15. }
been at it all week, thats all i got. please help
Reputation Points: 10
Solved Threads: 0
Newbie Poster
help_please is offline Offline
16 posts
since Mar 2010
Apr 10th, 2010
0
Re: Java Help
http://www.daniweb.com/forums/thread274782.html

What is it about the help I gave you in that thread that is insufficient? I gave you code examples, detailed explanations, etc. It seems like you want someone to do your project for you. To do your project, you need to know the following:

Classes, methods, a very basic understanding of Java Generics, how to use Iterators, how to use the equals() method (you don't need to know how to implement it though, but it might help if you read up on it), a basic understanding of how to use the Scanner class or how to otherwise read in from a file. I suggest you get started on reading the Sun Microsystems (now owned by Oracle) Java tutorials.

Oh, and as your incorrectly defined LinkedList (from your previous thread) showed me, you also need to read about variable scope. You can't declare a variable inside a for loop and expect it to exist once the loop finishes. What exactly have you been learning in class all this time?
Last edited by BestJewSinceJC; Apr 10th, 2010 at 10:39 pm.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Help finding the most occurring word
Next Thread in Java Forum Timeline: Saving BinaryTree to file.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC