In this tutorial, we are going to learn writing java program to check if the character is a vowel ( a, e, i, o, u) or any other alphabet other than vowels i.e. consonants.
For any input character, we have to check whether a character is a vowel or consonant.
For example
Case 1: If a user is given input a or A
The output should be “Vowel”
As we know that A is a vowel
Case2: If the user is given b or B
The output should be “consonant”
As we know that B is consonant
Check Given Character is Vowel or Consonant in Java
Output
Explanation
As we can see for the character ‘A’ output generated is “Vowel”, which is obvious as ‘A’ is a vowel and satisfying the ‘if ’ statement
Output
Explanation
Similarly, for the character ‘s’ output generated is “consonant”, as s is not a vowel and does not satisfy the ‘if ’ statement