Starting from:

$34.99

COP3330 Assignment 4 Solution



Programming Assignment 4 will consist of writing multiple short programs using material from modules 5, 7, and 8. For this assignment, are allowed to use the editor of your choice (e.g. Eclipse, IntelliJ, VS Code, Atom).
Each problem below should be self contained within its own folder. You will upload these folders to your GitHub site. Each folder must contain the java source code in its proper package structure. All problems should be in the same repository. To keep things simple, I suggest that you create a new repository on GitHub called <last_name>_PA4 and push your projects there.
MADE.
An example structure of your GitHub repository might be:


Grades for this program will be determined according to the rubic. If your project on GitHub does not contain the proper package structure, it will not be graded. This requirement is in place so that my graders can either pull your code directly from git or unzip it and run it without modification.

Problem 1
Create a class called DuplicateRemover. Create an instance method called remove that takes a single parameter called dataFile (representing the path to a text file) and uses a Set of Strings to eliminate duplicate words from 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. You will not receive credit if you use different file names, as my graders will not modify your code to make it work with their test files.


Problem 2
Create a class called DuplicateCounter. Create an instance method called count that takes a single parameter called dataFile (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. You will not receive credit if you use different file names, as my graders will not modify your code to make it work with their test files.


Assignment 4 Rubric
Criteria Ratings Pts
Problem 1: Problem 1 shall contain a public class called DuplicateRemover 2 pts Full
No
Problem 1: DuplicateRemover shall contain a method called remove 2 pts Full
No
Problem 1: Given a text file, dataFile, the remove method shall determine the unique words contained in dataFIle and store those unique words in the associated
DuplicateRemover object 2 pts
Full
No
Problem 1: The remove method shall terminate the program and alert the user when an exceptional IO event occurs 2 pts
Full
No
Problem 1: The remove method shall clean up any and all resources allocated during method execution 2 pts
Full
No
Problem 1: DuplicateRemover shall contain a method called write 2 pts
Full
No
Problem 1: Given a text file, outputFile, the write method shall print the current collection of unique words to outputFile 2 pts Full
No
Problem 1: The write method shall terminate the program and alert the user when an exceptional IO event occurs 2 pts
Full
No
Problem 1: The write method shall clean up any and all resources allocated during method execution 2 pts Full
No

Criteria Ratings Pts
Problem 1: Problem 1 shall contain a public class called Application 2 pts
Full
No
Problem 1: Application shall contain a main method 2 pts
Full
No
Problem 1: The main method shall create an instance of a DuplicateRemover called duplicateRemover 2 pts
Full
No
Problem 1: The main method shall use the write method of duplicateRemover to output the unique words of "problem1.txt" to a file called "unique_words.txt" 2 pts
Full
No
Problem 2: Problem 2 shall contain a public class called DuplicateCounter 2 pts
Full
No
Problem 2: DuplicateCounter shall contain a method called count 2 pts
Full
No
Problem 2: Given a text file, dataFile, the count method shall determine the number of occurrences of each word contained in dataFIle and store each unique word and its count in the associated DuplicateCounter object 2 pts
Full
No
Problem 2: The count method shall terminate the program and alert the user when an exceptional IO event occurs 2 pts
Full
No
Problem 2: The count method shall clean up any and all resources allocated during method execution 2 pts
Full
No


Criteria Ratings Pts
Problem 2: DuplicateCounter shall contain a method called write 2 pts
Full
No
Problem 2: Given a text file, outputFile, the write method shall print the current collection of unique words and their counts to outputFile 2 pts
Full
No
Problem 2: The write method shall terminate the program and alert the user when an exceptional IO event occurs 2 pts Full
No
Problem 2: The write method shall clean up any and all resources allocated during method execution 2 pts Full
No
Problem 2: Problem 2 shall contain a public class called Application 2 pts Full
No
Problem 2: Application shall contain a main method 2 pts Full
No
Problem 2: The main method shall create an instance of a DuplicateCounter called duplicateCounter 2 pts
Full
No
Problem 2: The main method shall use the write method of duplicateCounter to output the unique words of "problem2.txt" to a file called "unique_word_counts.txt" 2 pts
Full
No
Problem 1 has been correctly uploaded to GitHub 4 pts
Full
No

Criteria Ratings Pts
Problem 2 has been correctly uploaded to GitHub 4 pts Full
No

More products