Hi I am currently working on a project where I have to find the most frequently occurring word in an imported file. I have imported the file and can display what it says, but Im having trouble with this part: "Create a Word class that has a string and a count. Use a LinkedList
of Word objects. When you read a word from the novel check if it is in the list. If so increment the count. If not add it with count 1. After processing all of the words find the word with the highest count."
Here's my code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.*;
public class mostFrequentWord
{
public void Read()
throws FileNotFoundException
{
Scanner input = new Scanner(System.in);
FileReader reader = new FileReader("c:\\cecs\\cecs274\\test.txt");
Scanner in = new Scanner(reader);
in.useDelimiter(" [ ^ a - zA - Z ] + ");
while (in.hasNext())
{
String s = in.next().toLowerCase();
System.out.println(s);
}
}
}