Can somebody help improve this code for counting vowels in a string : <p>I need a code that counts the vowels in a given string, i can create the code that counts the vowels but the problem is that i can't build a code that will count the vowels till the end of the string , so far i have created this code , and i have to give everytime word.charAt(index) beacuse i cannot know how long the given word will be</p>

<pre><code>public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    System.out.print("Give a word: ");
    String word = scan.nextLine();
    int aCounter = 0;
    int eCounter = 0;
    int iCounter = 0;
    int oCounter = 0;
    int uCounter = 0;
    int yCounter = 0;
    for (int i=0; i &lt;= word.length(); i++){
    switch(word.charAt(0)){
    case 'a': aCounter++; break;
    case 'e': eCounter++; break;
    case 'i': iCounter++; break;
    case 'o': oCounter++; break;
    case 'u': uCounter++; break;
    case 'y': yCounter++; break;
    default:
        System.out.println("Letter not found");
    }
    switch(word.charAt(1)){
        case 'a': aCounter++; break;
        case 'e': eCounter++; break;
        case 'i': iCounter++; break;
        case 'o': oCounter++; break;
        case 'u': uCounter++; break;
        case 'y': yCounter++; break;
        default:
            System.out.println("Letter not found");
        }

    }


    if (aCounter &gt; 0) System.out.println("In the given word " + word + " are " + aCounter + " a");
    if (eCounter &gt; 0) System.out.println("In the given word " + word + " are " + eCounter + " e");
    if (iCounter &gt; 0) System.out.println("In the given word " + word + " are " + iCounter + " i");
    if (oCounter &gt; 0) System.out.println("In the given word " + word + " are " + oCounter + " o");
    if (uCounter &gt; 0) System.out.println("In the given word " + word + " are " + uCounter + " u");
    if (yCounter &gt; 0) System.out.println("In the given word " + word + " are " + yCounter + " y");










}
</code></pre>

<p>}</p>
