codescracker


java

Java Program to Check Vowel or Not



« Previous Program Next Program »


Check Vowel or Not

To check whether the input alphabet is a vowel or not in Java Programming, you have to ask to the user to enter a character (alphabet) and check if the entered character is equal to a, A, e, E, i, I, o, O, u, U. If it is equal to any one of the 10, then it will be vowel otherwise it will not be a vowel.

Java Programming Code to Check Vowel or Not

Following Java Program ask to the user to enter an alphabet to check whether it is a vowel or not, then display the result on the screen:

/* Java Program Example - Check for Vowel */
		
import java.util.Scanner;

public class JavaProgram
{
    public static void main(String args[])
    {
        char ch;
        Scanner scan = new Scanner(System.in);
		
        System.out.print("Enter an Alphabet : ");
        ch = scan.next().charAt(0);
		
        if(ch=='a' || ch=='A' || ch=='e' || ch=='E' ||
        ch=='i' || ch=='I' || ch=='o' || ch=='O' ||
        ch=='u' || ch=='U')
        {
            System.out.print("This is a Vowel");
        }
        else
        {
            System.out.print("This is not a Vowel");
        }
    }
}

When the above Java Program is compile and executed, it will produce the following result. Above Java Programming Example Output (for vowel):

Java Program check vowel

Above Java Programming Example Output (for not vowel):

check vowel in java

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test