title: Creating a program in java that counts sentences, paragraphs, letters and words
body: <p>I need to create a program that counts the frequency of characters in a text file, as well as the number of paragraphs words and sentences. </p>
  
  <p>I have a problem where when my program outputs the frequency of the letters the program outputs multiple outputs for each letter in the alphabet.</p>
  
  <p>Output should be like this:</p>
  
  <p>if input was "hello world!"</p>
  
  <p>(should output this for all letters of the alphabet):</p>
  
  <blockquote>
    <p>The letter a has been found 0 times </p>
    
    <p>the letter b has been found 0 times</p>
  </blockquote>
  
  <p>(until it reaches the letters that appear and then shows how many times they appear)</p>
  
  <blockquote>
    <p>number of paragraphs: 1</p>
    
    <p>number of sentences: 1</p>
    
    <p>number of characters:10</p>
    
    <p>number of words: 2</p>
  </blockquote>
  
  <p>I have been working on this for weeks now and still can't find a solution. </p>
  
  <pre><code>package SuperCounter2;
  
  import java.io.*;
  
  public class SuperCounter2 {
  
  public static void main(String[] args) throws IOException {
      File file = new File("//Users//4617621//Desktop//This is the most stupid assignment");
      FileInputStream fileStream = new FileInputStream(file);
      InputStreamReader input = new InputStreamReader(fileStream);
      BufferedReader reader = new BufferedReader(input);
  
      String line;
  
      int countWord = 0;
      int sentenceCount = 0;
      int characterCount = 0;
      int paragraphCount = 1;
      int whitespaceCount = 0;
  
      while ((line = reader.readLine()) != null) {
          int ci, i, j, k, l = 0;
          char c, ch;
          i = line.length();
  
          if (line.equals("")) {
              paragraphCount++;
          }
  
          if (!(line.equals(""))) {
              characterCount += line.length();
  
              String[] wordList = line.split("\\s+");
  
              countWord += wordList.length;
              whitespaceCount += countWord - 1;
  
              String[] sentenceList = line.split("[!?.:]+");
              sentenceCount += sentenceList.length;
          }
  
           int counter = 0;
  
          for (int m = 0; m &lt; line.length(); m++) {
              counter++;
          }
  
          for (c = 'A'; c &lt;= 'z'; c++) {
              k = 0;
              for (j = 0; j &lt; i; j++) {
                   ch = line.charAt(j);
              if(ch == c) {
                  k++;
                    System.out.println(" the character " + c + " has occured " + k + " times");
              }
          }
      }
    }
  
     System.out.println("Total word count = " + countWord);
      System.out.println("Total number of sentences = " + sentenceCount);
      System.out.println("Total number of characters = " + characterCount);
      System.out.println("Number of paragraphs = " + paragraphCount);
      System.out.println("Total number of whitespaces = " + whitespaceCount);
  
    }
  }
  </code></pre>