title: Program to print a word with most number of vowels
body: <p>I am unable to figure out what is wrong with this code. Whatever I provide as input, the code prints i as output. Any help is appreciated.</p>
  
  <pre><code>public class VowelClass{
  
  public static void main(String args[]){
  
  String input;
  System.out.println("Please enter your sentence: ");
  
  Scanner scan = new Scanner(System.in);
  input = scan.nextLine();
  
  int maxVCount = 0;
  String mostVowels = null;
  String[] words = input.split("");
  
  for (String word : words) {
  
    int vCount = 0;
    word = word.toLowerCase();
  
    for (int i=0; i&lt;word.length(); i++){
      char x = word.charAt(i);
      if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){
      vCount++;
      }
    }
     if (vCount &gt; maxVCount) {
      maxVCount = vCount;
      mostVowels = word;
     }
    }
      System.out.println("Word with most vowels is:");
      System.out.println(mostVowels);
    }
  }
  </code></pre>