// Earl Bergquist, Garfield High School
//  Word Count Method revealed

   public class WordCounting {
      public static void main(String[] args) {
         System.out.println(wordCount("how are you?"));
         System.out.println(wordCount("hello"));
         System.out.println(wordCount(" this string has wide spaces "));
         System.out.println(wordCount(" "));
      }
   
      public static int wordCount (String words) {
         int count = 0;
         if (words.charAt(0) != ' ') {
            count = count + 1;
         }
         for (int i=1; i < words.length() ; i++) {
            if (words.charAt(i) != ' ' && words.charAt(i-1) == ' ') {
               count++;
            }    
         }
         return count;
      }
   }


