In the English language, there are 26 alphabets. these alphabets are the group of vowels and consonants. A, E, I, O and U are vowels and remaining are consonants.
here you will learn how to check whether a character is a vowel or consonant.
Program For Vowels And Consonants Using Switch Case
class ConsonantVowel{
public static void main(String[] args)
{
char ch = ‘b’;
switch (ch)
{
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
System.out.println(ch + ” is vowel”);
break;
default:
System.out.println(ch + ” is consonant”);
}
}
}
As you see in the above example, we took a character b to whether it is a vowel or consonant but after executing the program the output is-
Output:
b is consonant