CS174: OOP - Drills - Vowel Counting

Developed by Professor Tralie and Professor Mongan.


Exercise Goals

The goals of this exercise are:
  1. To do proper string indexing
  2. To use conditional statements appropriately
  3. To keep track of auxiliary variables within loops
Fill in the method countVowels to count the number of vowels (both lowercase and uppercase, not including y or Y) in a string. Recall that the method charAt of the String class returns a character at a particular index, and, like arrays, strings are zero-indexed. For instance, if

String s = "I love CS";

, then

s.charAt(3)

returns the character o.

Recall also that the length() method of the String class returns the total number of characters in the string.

Welcome to our online modules system! Be sure to log in with your Urinus ID before you proceed. For example, Professor Tralie's ID is ctralie. If you are not an Ursinus student, that's fine! Just make something up, and you can still run everything