Answered step by step
Verified Expert Solution
Question
1 Approved Answer
input files: https://www.dropbox.com/s/6k69wsc2lf4r6pz/Frankenstein.txt?dl=0 https://www.dropbox.com/s/4txh2asc0nogqqp/CatInTheHat.txt?dl=0 Write a program that reads a text file and counts the number of times each English word appears. Display the 25
input files: https://www.dropbox.com/s/6k69wsc2lf4r6pz/Frankenstein.txt?dl=0
https://www.dropbox.com/s/4txh2asc0nogqqp/CatInTheHat.txt?dl=0
Write a program that reads a text file and counts the number of times each English word appears. Display the 25 most frequently used words. The program requires two classes, the main program and a separate class called UseCount to hold a word and its count. Recall that in Java each class requires a separate file. So your program will have two files: UseCount.java contains the Java code for the UseCount class CommonWords.java contains your main program (including the main method) You will create both files in JGrasp. Compile them both, and run the main-program file. See the g hints on the last pag e to be clear what goes in each file. The UseCount class needs two instance variables, one String to hold the English word and an int to hold the count of times this word appeared in the text. A constructor for UseCount should have one parameter to initialize the English word. The count should be initialized to one The main program needs to sort an array of UseCount objects. To be sorted, the UseCount class must implement the Comparable interface and include a method compareTo. The class statement for UseCount should look like: public class Usecount implements Comparable
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started