/// Returns the number of vowels in a piece of text.
int countVowels(String text) {
    String lower = text.toLowerCase();
    int count = 0;
    for (int i = 0; i < lower.length(); i++) {
        char letter = lower.charAt(i);
        if ("aeiou".indexOf(letter) >= 0) {
            count++;
        }
    }
    return count;
}

void main() {
    IO.println(countVowels("Programming in Java"));
}

// From Groundwork, chapter 8 (ch08-strings-as-data), box 13.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch08_13.java
