title: Counting words with minimum length in java
body: <p>Write your code in the file WordCount.java. Your code should go into a method with the following signature. You may write your own main method to test your code. The graders will ignore your main method:</p>
  
  <pre><code>public static int countWords(String original, int minLength){}
  </code></pre>
  
  <p>Your method should count the number of words in the sentence that meet or exceed minLength (in letters). For example, if the minimum length given is 4, your program should only count words that are at least 4 letters long.</p>
  
  <p>Words will be separated by one or more spaces. Non-letter characters (spaces, punctuation, digits, etc.) may be present, but should not count towards the length of words.</p>
  
  <p>Hint: write a method that counts the number of letters (and ignores punctuation) in a string that holds a single word without spaces. In your countWords method, break the input string up into words and send each one to your method.</p>
  
  <p>I am trying to get the minimum length of the word in the code, without it counting punctuation marks and such. how do i do that? Also, I will get rid of the main method as it will be added automatically. How do i make the program automatically add a space after the last word?</p>
  
  <pre><code>public class WordCounts
  {
  public static void main(String[] args)
  {
      Scanner in = new Scanner(System.in);
      System.out.print("Enter a sentence: ");              
      String sentence = in.nextLine();
  
      System.out.println("minLength");
      int minLength=in.nextInt();
  
      System.out.print("Your sentence has " + countWords(sentence,minLength)+ " words.");
  }
  
  public static int countWords(String str, int minLength)
  {
  int count = 0;
  int c=0;
  
  for (int i=0;i&lt;=str.length()-1;i++)
  {
      if (str.charAt(i) != ' ')
      {
          if(str.charAt(i)&gt;='a' &amp;&amp; str.charAt(i)&lt;='z') //to check only      for alphabets.
          c++;
  
      }
      if(c&gt;=minLength)
      {
           count++;
           c=0;
      }
      }
  return count;
  
  }
  }
  </code></pre>