Java Program To Check Whether An Alphabet Is Vowel Or Consonant
Chapter:
Miscellaneous
Last Updated:
25-08-2017 09:51:26 UTC
Program:
/* ............... START ............... */
public class JavaVowelOrConsonant {
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");
}
}
/* ............... END ............... */
Output
Notes:
-
In the above program, 'i' is stored in a char variable ch. In Java, you use double quotes (" ") for strings and single quotes (' ') for characters.
- If ch is any of the character in bracket ('a', 'e', 'i', 'o', 'u'), then it is a vowel, this is done using a simple if..else statement.
Tags
Check Whether An Alphabet Is Vowel Or Consonant, Java, Miscellaneous