Input a character and check it vowel or not

Input a character and check it vowel or not

Previous Home Next

 

Input a character and check it vowel or not

 

 //Program for check word is vowel or not
package r4r.co.in;

import java.io.*;

public class NewClass {

    public static void main(String[] args) throws IOException {
        BufferedReader Digit = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter the Word:");
        String s1 = Digit.readLine();

        String s2[] = {"a", "e", "i", "o", "u"};  //Create an array and insert with vowel

        //Code for vowel

        for (int i = 0; i < s2.length; i++) {
            if (s2[i].equalsIgnoreCase(s1)) {
                System.out.print("Word is Vowel:");
                break;
            } else {
                System.out.print("Word is NotVowel:");
                break;
            }
        }

    }
}

Enter the Word:
A
Word is Vowel

 

or

Enter the Word:
L
Word is NotVowel

Previous Home Next