Problem 1

Create a class called DuplicateRemover. Create an instance method called remove that takes a single parameter called dataFile of type String (representing the path to a text file) and uses a Set of Strings to eliminate duplicate words from the file referenced by dataFile. The unique words should be stored in an instance variable called uniqueWords. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the words contained in uniqueWords to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist.

Create a separate class called Application that contains a main method which illustrates the use of DuplicateRemover by calling both the remove and write methods. Your input file must be called problem1.txt and your output file must be called unique_words.txt. Your input file should be located within your project structure so that you can reference it with the relative path of "problem1.txt", and not an absolute path.

You may consider a word to be any sequence of characters separated by whitespace. You do not need to worry about removing punctuation, but you can if you'd like. Additionally, capitalization should not matter when determining the uniqueness of a word.

You must handle any exceptions that will be thrown within the method that throws them. You are forbidden from simply adding a "throws IOException" to your method signatures.

Your program should work on any text file. The TA's will provide their own version of problem1.txt when they run your code.

Problem 2

Create a class called DuplicateCounter. Create an instance method called count that takes a single parameter called dataFile of type String (representing the path to a text file) and uses a Map of Strings to count how many times each word occurs in dataFile. The counts should be stored in an instance variable called wordCounter. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the contents of wordCounter to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist.

Create a separate class called Application that contains a main method which illustrates the use of DuplicateCounter by calling both the remove and write methods. Your input file must be called problem2.txt and your output file must be called unique_word_counts.txt. Your input file should be located within your project structure so that you can reference it with the relative path of "problem2.txt", and not an absolute path.

You may consider a word to be any sequence of characters separated by whitespace. You do not need to worry about removing punctuation, but you can if you'd like. Additionally, capitalization should not matter when determining the uniqueness of a word.

You must handle any exceptions that will be thrown within the method that throws them. You are forbidden from simply adding a "throws IOException" to your method signatures.

Your program should work on any text file. The TA's will provide their own version of problem1.txt when they run your code.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be 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 complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.