Write a Java-program to check the given character is vowel or consonant

Write a Java-program to check the given character is vowel or consonant

Program
public class Main
{
	public static void main(String args[])
	{
        char ch='r';
        if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
        {
            System.out.println("Vowel");
        }
        else
        {
            System.out.println("Consonant");
        }
	}
}	

Output:

Consonant

Using CommandLine Arguments
public class Main
{
	public static void main(String args[])
	{
        char ch;
        ch=args[0].charAt(0);
        if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
        {
            System.out.println("Vowel");
        }
        else
        {
            System.out.println("Consonant");
        }
	}
}	

Output:

Consonant

Using Scanner Class
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
        char ch;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter character");
        ch=s.next().charAt(0);
        if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
        {
        System.out.println("Vowel");
        }
        else
        {
        System.out.println("Consonant");
        }
	}
}	

Output:

Enter character
r
Consonant





More Questions


29 . Write a Java-program to check the given number is valid or invalid(value must between 20 and 30)
30 . Write a Java-program to check the given character is vowel or consonant
31 . Write a Java-program to check the given character is small letter or not
32 . Write a Java-program to check the given character is capital letter or not
33 . Write a Java-program to check the given character is number or not
34 . Write a Java-program to check the given character is symbol letter or not
35 . Write a Java-program to calculate simple interest with following condtions
36 . Write a Java-program to print age
37 . Write a Java-program to print Max Number amoung the three numners using else if
38 . Write a Java-program to check the given character is vowel or consonant( Character must be small letter)
39 . Write a Java-program to check Odd or Even number program using nested if condition(value must be positive)