38. JAVA Program to Check given Input is Vowel or Not using Switch Case.
How does this program work?
- In this program you are going to learn about how to Identify the given input is Vowel or Consonant using Switch Case in Java.
Here is the code
//To check a letter Vowel or Consonant.
import java.util.Scanner;public class character
{
public static void main(String[ ] arg)
{
int i=0;
System.out.println("Enter a character : ");
Scanner obj=new Scanner( System.in);
char ch=obj.next( ).charAt (0);
switch(ch)
{
case 'a' :
case 'e' :
case 'i' :
case 'o' :
case 'u' :
case 'A' :
case 'E' :
case 'I' :
case 'O' :
case 'U' :
i++;
}
if(i==1)
System.out.println(" character "+ch+" is Vowel");
else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
System.out.println("character "+ch+" is Consonent");
else System.out.println("Not analphabet");
}
}