title: Java - Counting the vowels in string
body: <p>The code below is supposed to count the syllables in a string based upon the following principles:</p>
  
  <ol>
  <li>It should count a single vowel or a set of vowels as a syllable.</li>
  <li>If a lone "e" is at the end of the string and there is more of vowels in the rest of the string, then "e" is not a syllable.</li>
  <li>If a lone "e" is at the end, and there is one or more vowels next to "e" and there is also more vowels in the rest of the string, then "e" is a syllable.</li>
  </ol>
  
  <p>My code does the first two rules but not the last one. Can someone help me modify this code in a way that the 3rd rule is fulfilled as well? </p>
  
  <pre><code>protected int countSyllables(String word) {
      String input = word.toLowerCase();
      int syl = 0;
      boolean  vowel  = false;
      int length = word.length();
      //check each word for vowels (don't count more than one vowel in a row)
      for(int i=0; i&lt;length; i++) {
          if        (isVowel(input.charAt(i)) &amp;&amp; (vowel==false)) {
              vowel = true;
              syl++;
          } else if (isVowel(input.charAt(i)) &amp;&amp; (vowel==true)) {
              vowel = true;
          } else {
              vowel = false;
          }
      }
      char tempChar = input.charAt(input.length()-1);
      //check for 'e' at the end, as long as not a word w/ one syllable
      if ((tempChar == 'e')  &amp;&amp; (syl != 1)) {
          syl--;
      }
      return syl;
  }
  </code></pre>