Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Word Count Program Help....

    Okay so I'm having problems with this Word Count program. The program is supposed to read a stream from a .txt file (which it does). The problem is I need it to separate each word from the paragraph and add them to the array WC. It then needs to Increment the count of that word. It also needs to store each object and likewise search through that array looking for a word match. Second, I need to isolate each word in the input string which generally contains multiple words.

    Ive attached the program and the class with an area where I need to put statements.

    Thanks. I'm just new to computer science and need help figuring this one out.
    Attached Files Attached Files

  • #2
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
                  String[] line = S.split("\\W");
                  for (int i = 0; i < line.length; i++) {
                    if (!line[i].trim().isEmpty()) {
                      WordCount word = new WordCount(line[i]);
                      word.Increment();
                      WC[next] = word;
                      next++;
                    }
                  }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •