The objective of this assignment is to refresh your knowledge of how to solve programming problems involving loops, arrays, methods, and files. Come to class lecture sessions to learn many of the details you will need to complete this assignment. This will be true for future assignments, also.
You must define the following methods.
public String[] readWords(String filename)
String line = scanner.nextLine(); String[] wordsThisLine = line.trim().replaceAll("[^a-zA-Z ]", "").toLowerCase().split("\\s+");
public String[] unique(String[] words)
Test your code with your main method. Here is an example. Create a text file named test.txt that contains the lines
Here are some words on multiple lines. When you read the file you should find twenty-two (22) words, but only nineteen unique words.
When you test your code from the command line you should see
> javac P1.java > java P1 test.txt From test.txt I read 22 words and found 19 unique ones.
Now try your code on something big, like, ummm, let's try The Pickwick Papers, by Charles Dickens! Look for the plain text file at The Gutenberg Project. If you save the text file in a file named PickwickPapers.txt, then you should get this output.
> java P1 PickwickPapers.txt From PickwickPapers.txt I read 310054 words and found 18244 unique ones.
Submit your P1.java file via the online checkin system.