Assume letters A, E, I, O, and U as the vowels. Write a program that prompts the user to enter a string and displays the number of vowels and number of consonants in the string.
Breaking it down
Once the input has been captured from the user, we can convert the String into a Instream by calling phrase.chars(). Next using a IntPredicate that checks if character is a vowel we filter the stream and count the number of vowels and consonants. You will notice that we only have to create one predicate and call the predicate.negate() which will return the opposite value of the predicate.