How to find out total number of vowel in given string?

How to find out total number of Vowel in given String?

				
					import java.util.Scanner;

public class CheckVowelWord {
	public static void main(String args[]) {
		System.out.println("enter string :");
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		System.out.println("The vowel are :-");
		CheckVowelWord.word(s);
	}

	public static void word(String str) {
		int i;
		for (i = 0; i < str.length(); i++) {
			if ((str.charAt(i) == 'a') || (str.charAt(i) == 'e') || (str.charAt(i) == 'i') || (str.charAt(i) == 'o')
					|| (str.charAt(i) == 'u')) {
				System.out.println(str.charAt(i));
			}
		}
	}
}
				
			

Input :-
enter string : welcome
Output :- The vowel are :
e
o
e

Leave a Comment

Your email address will not be published. Required fields are marked *