Alright. So this is just one part of my multiple part project.
I need to try and get the frequency of how many times each word of 'X' amount of letters shows up.
I am pretty bad at using arrays, but I realize this is the best way to do it and the only way with what I've learned so far.
Here is what I have so far. It prints out like everything. Every word from the file line by line and also a long list of all 15 digits and for each line one of the digits goes up.
How can I get the information from only the last line that has the final count?
private int wordCount;
private int lineCount;
private int charCount;
private double avgWordLength;
private final int charactNumbers = 26;
private int[] high = new int[charactNumbers];
private int alphabet;
private int otherChars = 0;
private final int LIMIT = 15;
int[] wordLength = new int[LIMIT];
int len;
public void wordFreq(String filename)
{
File inFile = new File(filename);
try { Scanner file = new Scanner(inFile);
while ((file.hasNext()))
{
String s = file.next();
System.out.println (s);
int wat = s.length();
wordLength[wat]++;
if (wat != 0)
{
for (int dogs : wordLength)
System.out.print (dogs + " ");
}
}
} catch (IOException e) {
}
}