OneCompiler

java program to check the character whether it is 'vowel' or 'consonant' given by user.

276

import java.util.*;

public class HelloWorld {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
char ch=sc.next().charAt(0);
int n=ch;
if((n>=97 && n<=122)||(n>=65 && n<=90))
{
if(n==97 || n==101 || n==105 || n==111 || n==117 ||n==65 || n==69 ||n==73 ||n==79 ||n==85)
{
System.out.println("vowel");
}
else
{
System.out.println("consonant");
}
}
else
{
System.out.println("please enter a valid character.");
}
}
}