Write a  Java Program to Check Whether an Alphabet is Vowel or Consonant

Java Program to Check Whether an Alphabet is Vowel or Consonant

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java  language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Java Program to Check Whether an Alphabet is Vowel or Consonant
Java Program to Check Whether an Alphabet is                       Vowel or Consonant

Write a Java Program to Check Whether an Alphabet is Vowel or Consonant

PROGRAM: Java Program to Check Whether an Alphabet is Vowel or Consonant

/* Java Program to Check Whether an Alphabet is Vowel or Consonant */
public class VowelConsonant {

    public static void main(String[] args) {

        char ch = 'i';

        if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
            System.out.println(ch + " is vowel");
        else
            System.out.println(ch + " is consonant");

    }
}
2.Check whether an alphabet is vowel or consonant using switch statement

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

 

Leave a Reply

Your email address will not be published. Required fields are marked *