Write a new class named Assignment3. This class will open a text file, read its contents, and count its words.

Requirements:

  • Add two private member variables, one to store the name of the file, and another to store the count of words in the file.
  • Add a public constructor. Its only argument is the name of the file (you pick an appropriate type for this argument). Use the constructor to initialize one of the variables from requirement #1.
  • Add a public "getter" for the word count, name it "getTotalWordCount". Use an appropriate return type. This will return the number of words contained within the input file.
  • Add a public "getter" for the file name, name it "getFileName". Use an appropriate return type.
  • Add a public function named "processFile". It returns nothing and accepts no arguments. This function will:
  • Open the input text file.
  • Read the file's contents into a buffer.
  • Close the file.
  • Convert the buffer into a String.
  • Tokenize the string and use the tokenizer to initialize your word count variable.
  • Handle appropriate exceptions.

Bonus requirements:

  • Make sure you get the requirements above done first. I recommend you submit the solution before attempting the bonus.
  • Add a private member variable that will store the most frequent word in the file.
  • Add a "getter" for the variable in bonus requirement #2. Call it getMostFrequentWord(). Use an appropriate return type.
  • Add code to your processFile function that counts the number of times each word appears in the file. A HashMap is a good choice for this.
  • Add code to your processFile function sets the value of the variable added for bonus requirement #2. Don't worry about ties.
  • Add a "getter" called getCountForWord(). It accepts a single argument, the word to search for. Use an appropriate type for the argument and the return value.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.