Problem Statement | |||||||||||||
In the English language, a syllable can be loosely defined as a unit of uninterrupted sound. One can usually count the number of syllables in an English word by 'sounding it out'. In general, however, it is difficult to write a program to count the number of syllables in a word.
Here, we'll use the following procedure to count syllables: Each group of vowels {'A', 'E', 'I', 'O', 'U'} appearing in the word will add one syllable to the total number of syllables in the word. A group of vowels is either separated by consonants (all letters A-Z that are not vowels) or the group appears at the beginning or end of the word. So, for example, the word "HELLO" contains 2 syllables according to the above procedure due to the vowels 'E' and 'O'. The word "FOOBAR" also contains 2 syllables, even though there are 3 vowels in the word. This is because the two 'O' vowels are considered one group of vowels. Finally, the word "TELEVISION" contains 4 syllables. Create a class SyllableCounter containing a method countSyllables which takes a String word as input. The method should return an int corresponding to the number of syllables in word according to the above algorithm. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | word will contain between 3 and 50 characters inclusive. | ||||||||||||
- | word will contain only uppercase letters ('A'-'Z'). | ||||||||||||
- | word will contain at least one vowel and at least one consonant. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|