HOMEWORK ASSIGNMENT #5
Assigned Date: Thursday,
April 1, 2004
Due Date: Monday, April 12, 2004
Due Time: Noon
Updated: Thursday, April
Source filename to be submitted: ModularWordStatistics.java
Skills Developed: Modularization and methods.
Documentation and submission: See instructions in the first homework assignment.
Your assignment is to modularize the previous program,
You should have the following non-static methods (use the
exact names specified):
- Initialize: This method
initializes your parallel arrays.
- ProcessInput: This void method
reads all input text and populates the parallel arrays as described in the
previous assignment. To do so, it
- ProcessLine: This void method is
given a single line of text (a String)
and populates the parallel arrays accordingly. To do so, it calls:
- FindWordInList: This int method is given a word (a String) and the two parallel
arrays (list of words and list of frequencies). If the word is in the list of words,
it returns its index; otherwise it returns –1 (to indicate that this is
a new word).
- Sort: This void method sorts the
parallel arrays in decreasing order of word frequency (most frequent word
- FindMinIndex: This int method returns the index of
the most frequent word given the parallel arrays
- Swap: This void method is given the parallel arrays and two indices, x and
y. It swaps the array elements at
- Output: This void method outputs the
information stored in the parallel arrays as described in the previous
Your methods (and program) should be documented as per the
departmental documentation standards.
Include Purpose, Precondition, and Postcondition documentation for each
method. For the Purpose documentation do not simply cut and paste the
above – rewrite them appropriately.
Document the information flow for each parameter (/* in */, /* out */, or /*
in|out */). If a method uses
local variables, declare them at the top of its body, and fully document
Here is a draft of the
solution, in case you had some difficulties with the previous assignment.
- Test your
program with different inputs to ensure that it works properly.
you are satisfied that your program works, run your program against the
Then run your program against the files
Compare the output with the output
from the previous program.