word with the most vowels
<p>I am trying to find a word with the most vowels in a sentence inputted by the user. Right now when I call this method it works fine with a shorter sentence. But when it gets over 7 words it doesn't print out the word with the most vowels. I can't seem to spot the error =(</p>

<p>I thank you guys in advance!</p>

<pre><code>private static void getWordMostVowel(String sentence) {

    String word = "";
    String wordMostVowel = "";
    int temp = 0;
    int vowelCount = 0;
    char ch;

    for(int i = 0; i &lt; sentence.length(); i++){
        ch = sentence.charAt(i);

        sentence = sentence.toLowerCase();

        if (ch != ' '){
            word = word + ch;
            if ( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
                vowelCount++;
        }

        else {
            if(vowelCount &gt; temp){
                temp = vowelCount;
                wordMostVowel = word;
            }
            word = " ";
        }
    }

    System.out.println("The word with the most vowels is: " + " " + wordMostVowel);

}
</code></pre>