Java Program to check whether a given character is vowel or consonants using if else


Program
import java.util.*; public class VowelConsonantProgram { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Enter a character"); char ch = s.next().charAt(0); if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ) System.out.println(ch + " is vowel"); else System.out.println(ch + " is consonant"); } }
Input
Output