Java if statement check if a character is vowel or consonant

Description

Java if statement check if a character is vowel or consonant

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        char ch = 'o';

        if (ch == 'a' || ch == 'A')
            System.out.println(ch + " is vowel.");
        else if (ch == 'e' || ch == 'E')
            System.out.println(ch + " is vowel.");
        else if (ch == 'i' || ch == 'I')
            System.out.println(ch + " is vowel.");
        else if (ch == 'o' || ch == 'O')
            System.out.println(ch + " is vowel.");
        else if (ch == 'u' || ch == 'U')
            System.out.println(ch + " is vowel.");
        else/*from   ww  w .  j a  v  a  2  s  .  co  m*/
            System.out.println(ch + " is a consonant.");
    }

}



PreviousNext

Related