ITEC 120
L04b: Vowel Counter

Objectives

To successfully complete this lab you will use loops and String methods to identify and count vowels in a String.

Assignment

Develop a program named Vowel which will ask the user to enter a sentence and report how many vowels are in the sentence. Your program will repeat until the user enters "Quit".

You'll need some String methods to accomplish this task: charAt, equals, and length plus maybe some others. Look them up to figure out how to use them. Look at the list of String methods and see what else might be useful to you.

Here is one possible output for this program:

Welcome to the vowel counter.
Enter a sentence (type Quit to quit): This is one awesome lab!

There are 9 vowels in the sentence
"This is one awesome lab!"
They are: iioeaeoea 

Enter a sentence (type Quit to quit): Today is my birthday.

There are 5 vowels in the sentence
"Today is my birthday."
They are: oaiia 

Enter a sentence (type Quit to quit): quit
Thanks for using the vowel counter.

Helpful hints

Notice that 'a', 'e', 'i', 'o', and 'u' are vowels. For this exercise, you may assume 'y' is not a vowel.

More than one loop is necessary for this program: one to ask the user to enter sentences until they type "Quit", and another to process each character of the String. Get one working first, then add the other.

Refine your program

In this example, all the vowels happen to be lowercase, however, your code should work for uppercase vowels as well. Also notice that in the example, the user typed "quit", all lowercase. Your program should quit no matter what combination of uppercase and lowercase letters the user types, e.g. "Quit", "QUIT", or "quIT" should all quit the program.

Submit Your Assignment

Submit Vowel.java to the L04b dropbox on D2L.