For this assignment you are to write a program that handles text files. The assignment requires three classes (plus library classes); we've given you two - FreqStudy, the driver, and another class, WordCount.
FreqStudy.java

As demonstrated in the example run above, an external text file name is entered first. Then any number of individual words are entered, all lower case, and separated by spaces. After doing its analysis, the program then displays a chart that gives the frequencies in the text of the indicated words, to four decimal places. Thus 2.42% of all of the words in the Heart of Darkness text file are "I", 1.33% are "he", and so forth. Pretty clearly Heart of Darkness is narrated in the first person, and is mostly about men.

Further requirements and tips:

* you MUST use an array of WordCount objects to keep track of the occurrences of the indicated words.

* Use printf from Chapter 5 to format your output.

* If s is a String, then this String class method call:
s.split(" "); // this is a single space surrounded by quote marks

returns an array of strings that consists of the tokens (separated by white space) in s. For example, given
String s = "i he his she hers";
String[] words = s.split(" ");

Then words is this five element array of strings: {i, he, his, she, hers}

At the course website we've provided some tips for solving this problem, and in addition we've provided some text files that you might want to experiment with. Thus we urge you to check the ProgramNotes link at the course website for further information about the assignment.

First you need to properly format the posted code. Nested statements need to be indented 3-4 spaces.
Not all statements should start in the first column.

Which part of the assignment are you working on and having problems with?
Please ask some specific questions about the problem.

April 16th, 2013, 04:13 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

I am working on the last code that I posted. I am trying to read in a handful of words on one line. Then every time you read in a new line form a file I want to check if any of the words you're reading in is one of those. If it is, you count it (and throw it away) otherwise you just throw it away.

And he requirements that I posted above, Im trying to be specific but I am just so SO confused.

April 16th, 2013, 04:24 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

What part are you having problems with?
trying to read in a handful of words on one line.
check if any of the words you're reading in is one of those.
If it is, you count it

April 16th, 2013, 05:00 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

Yes, it is supposed to use text files then count the words you enter in that file. But when I enter which words to count it doesn't work. I don't know exactly which part of my code if wrong for this though. Sorry, confusing I know.

April 16th, 2013, 05:05 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

Work on one problem at a time:
can the program do this: read in a handful of words on one line.

--- Update ---

First you need to properly format the posted code. Nested statements need to be indented 3-4 spaces.
Not all statements should start in the first column.

April 16th, 2013, 05:12 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

Yes the code reads in the words that I type in the Java prompt to box.

April 16th, 2013, 05:19 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

If the program is able to get a line of words, how about the next step:
check if any of the words you've read in is one of those being searched for.

April 16th, 2013, 05:23 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

how would you check that?

April 16th, 2013, 05:29 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

How would you do it manally? Given some words on a line what steps need to be done to check if any of the words are in another list somewhere?

April 16th, 2013, 05:36 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

you would need to scan the other document to search for the words you are looking for

April 16th, 2013, 05:38 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

Break the process down into simple, single steps. Your suggestion has too many hidden steps.
Give a line with several words, what needs to be done first?

April 16th, 2013, 05:42 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

read the line of words. Then go through each word...? IDK AH :(

April 16th, 2013, 05:48 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

Where are the words that are to be counted? How does the program put them there?

I assume the words to be counted have been saved somewhere before the search is made through the text to count the occurrences of the words.

I haven't read the assignment so I don't know what the program is supposed to do. You need to do that.
Then ask specific questions about the steps that you are having problems with.

April 16th, 2013, 05:52 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

i posted the assignment above. I would ask more specific questions but I am so confused I really don't even know what to ask. We are pulling from files for example (Document.txt) and the program is supposed to search those files for the words we type into the box and count how many times they occur.

April 16th, 2013, 06:03 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

Is the program given a list of words to search for?
How does the program get that list of words and what does it do with the list?
Have you written the code to do that yet?

--- Update ---

Be sure to properly format any code you post.

April 16th, 2013, 06:14 PM

sc23

Re: JAVA HELP PLEASEEEEEEEE

no you can search any words you want. The words can be typed into the prompt box when you run the code. The scanner is used to create this.

April 16th, 2013, 06:21 PM

Norm

Re: JAVA HELP PLEASEEEEEEEE

What I'm asking about is: What is done with the words to be counted?
How are the words read into the program and where does the program save them?
Once they are saved some place, the program can read the document to search for them.