Skip to content
Home » Blog » Java Program to check Vowel or Consonant using Switch Case

Java Program to check Vowel or Consonant using Switch Case

In this Program you’ll learn Java Program to check Vowel or Consonant using Switch Case, so Before moving with program lets first understand what exactly is Vowel and Consonant which will help us understand the program.

The Alphabet A,E,I,O and U are Vowels irrespective of their case (Smallcase/UPPERCASE). And the remaining Alphabets are Consonants.

Example: Program to check Vowel or Consonant using Switch Case

Here we will write Java Program to check Vowel or Consonant using Switch Case, here when the user enters the value the program checks all the cases and then till it reaches Case U. In this way we can Identify the character is consonant or Vowel.

Program to check Vowel or Consonant using Switch Case

public class VowelConsonant {

    public static void main(String[] args) {

        char ch = 'Z';

        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");
        }
    }
}

When you run the program, the output will be:

i is vowel

Output 2:

P is a Consonant
Java Program to check Vowel or Consonant using Switch Case
Java Program to check Vowel or Consonant using Switch Case

Related Programs

Ask your questions about Java Program for decimal to hexadecimal conversion in Java and clarify your/others doubts by commenting. Documentation.

Please write to us at [email protected] to report any issue with the above content or for feedback.