Assignment Three
This assignment is to write a Java program to:
prompt the user for a text file name
read words (a word is a sequence of letters) from the file and count the number of times each word appears.
display each word along with the corresponding number of times that word appeared is the file.
Requirements:
Design a public class Word in a separate file satisfying:
The class must have 2 private fields (String for a word and int for it's count)
The class must override the class Object's equals, hashCode and toString methods
The class may have other methods such as accessors and modifiers
The class must implement the Comparable<Word> interface so that the ''natural order'' is word alphabetic order.
Use a JOptionPane to prompt the user for the file name
Store the words and counts in an ArrayList<Word> object
Sort the ArrayList<Word> using the Collection class sort method.
Display the results in a JTextArea in a JScrollPane in a JOptionPane.
Write a class that implements the Comparator<Word> interface that orders the words in word count order. If two words have the same count then order them alphabetically. Construct an object of this class.
Sort the ArrayList<Word> again using the Collections sort method using the comparator object from the previous step to sort the words in word count order
Display the results again on a JTextArea in a JScrollPane in a JOptionPane
This assignment is due on October 10th at the beginning of class.