title: Program that reads file input and displays proportion of the length of the letter and so on
body: <p>I have an assignment due two days and I have been trying a lot of days to do this, but I am burned, tried to come back to it, still no progress.</p>
  
  <p>THE ASSIGNMENT is the following:</p>
  
  <p>Java program that computes the above statistics from
  any text file. Here’s what it might look like in action:
  Name of the input file: example.txt
  The proportion of 1-letter words: 3.91% (74 words)
  The proportion of 2-letter words: 18.52% (349 words)
  The proportion of 3-letter words: 24.24% (456 words)
  The proportion of 4-letter words: 19.80% (374 words)
  The proportion of 5-letter words: 11.33% (212 words)
   …
   …
  The proportion of 12-letter words: 0.45% (8 words)
  Proportion of 13- (or more) letter words: 0.51% (9 words)</p>
  
  <p>Now In order to do this, I thought to divide my program into three methods: Read the method, count the letters and distinguish them and finally display it as the example above. Now that I said that, here is my code right now:</p>
  
  <pre><code> /*like make smaller functions
  where each function has one task
  like to loop through the file and return an array of words
  then use that as input to another function whose purpose is to count the 
  letters
  and then pass that array into a function for printing that.
  */
  
  
  import java.io.*;
  import java.util.Scanner;
  class Autorship {
  
  
  public static void main(String[] args) {
      try {
          System.out.println("Name of input file: ");
          Scanner sc1 = new Scanner(System. in );
          sc1.useDelimiter("[^a-zA-Z]");
          String fname = sc1.nextLine();
          sc1.close();
  
          sc1 = new Scanner(new FileReader(fname));
          sc1.useDelimiter("[^a-zA-Z]");
          String line;
          System.out.println(WordCount(fname, sc1));
  
  
  
      } catch (FileNotFoundException e) {
          System.out.println("There was an error opening one of the files.");
      }
  
  
  }
  
  public static int WordCount(String fname, Scanner sc1) {
  
  
      int wordCount = 0;
      int lineCount = 0;
      while (sc1.hasNextLine()) {
          String line;
          line = sc1.nextLine();
  
          lineCount++;
  
          String[] strings = line.split(" ");
          int[] counts = new int[14];
  
          for (String str: strings)
              if (str.length() &lt; counts.length) counts[str.length()] += 1;
  
          System.out.println("This is counts length: " + counts.length);
          for (int i = 1; i &lt; counts.length; i++)
  
              System.out.println(i + " letter words: " + counts[i]);
  
  
  
      }
  
      return 0;
  
  
  }
  
  
  }
  </code></pre>
  
  <p>Now please <strong>I do not want the answer, as that would be plagiarism, and I am not that kind of person</strong>, I just want a bit of help to continue to progress, I'm so stuck right now, thanks ^^</p>