Loading...
Loading...
A school app gives a small reward for messages with many vowels. Read one message and count its vowels and consonants.
Vowels are a e i o u in either case. Every other English letter is a consonant. Digits, spaces and punctuation are neither, so they are not counted.
Vowels: v and then Consonants: c.Example 1
Input
Hello World
Output
Vowels: 3 Consonants: 7
Vowels e, o, o. The space is not counted.
Example 2
Input
UPI 2500 sent!
Output
Vowels: 3 Consonants: 4
U, I and e are vowels. Digits and ! are skipped.
Try the problem first. Open one hint at a time.
Change the whole line to lowercase first, so you only check small letters.
For each character, first check that it is a letter (between 'a' and 'z'). Only then decide vowel or consonant.
"aeiou".indexOf(ch) >= 0 is a short way to ask "is ch a vowel?".
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor