Problem Statement
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
Definition
- Class:
- SyllableCounter
- Method:
- countSyllables
- Parameters:
- String
- Returns:
- int
- Method signature:
- int countSyllables(String word)
- (be sure your method is public)
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
"HELLO"
Returns: 2
"VOLUME"
Returns: 3
Note that this returns 3 because of the vowels O, U, and E. Your method should return 3 despite the fact that in spoken English, the E at the end doesn't actually create a syllable.
"TELEVISION"
Returns: 4
"BOOKKEEEEEEEEEEEEPER"
Returns: 3
"THISISASENTENCE"
Returns: 6
"SLKJSGLKAKHDGHELHDGILKLHDGOLOOOOOL"
Returns: 5
"AEIOUS"
Returns: 1
"LSKHOIEOHWLHSOGIHOIWHEOHWOCAAAAOIHOGDHOWEIOHASDOIH"
Returns: 12
"HELLOWORLD"
Returns: 3
"HHHHHHHHHHHHHHHHHHHHHHA"
Returns: 1
"TESTARGUMENTTHISISA"
Returns: 7
"NOHIDDENMESSAGESHERE"
Returns: 8
"TRYHASONESYLLABLE"
Returns: 5
"SYLLABLE"
Returns: 2
"ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY"
Returns: 10
"KWYJIBO"
Returns: 2
"ILOVETHESIMPSONSTHEYARESOOOOOOOOCOOL"
Returns: 11
"AABACADAEAFAGAHAIAJAKALAMANAPAQARASATAUAVAWAXAYAZA"
Returns: 22
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZ"
Returns: 1
"AEIOUZ"
Returns: 1
"ZAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
Returns: 1
"ZAEIOUOUOEUOEUOEUOEUOEUOEUEUE"
Returns: 1
"HEA"
Returns: 1
"SLKJSGLKAKHDGHELHDGILKLHDGOLOOOOOL"
Returns: 5
"ABA"
Returns: 2
"AZX"
Returns: 1
"ABAB"
Returns: 2
"ABC"
Returns: 1
"HEAUL"
Returns: 1
"AACCAEU"
Returns: 2
"AEIOUVVAEIOU"
Returns: 2
"EHH"
Returns: 1
"OBYBYBYBYBYBO"
Returns: 2
"RACNGGRNYTTRLQOASHIYGYFTXIMOADDPDIGBJTPZQGWZFGUYFL"
Returns: 7
"AAN"
Returns: 1