|
| 1 | +import java.util.Scanner; |
| 2 | + |
| 3 | +public class CountVowel{ |
| 4 | + public static String[] split(String s){ |
| 5 | + int c = 0; |
| 6 | + for (int i=0;i<s.length();i++){ |
| 7 | + if(s.charAt(i)==' '){ |
| 8 | + c+=1; |
| 9 | + } |
| 10 | + } |
| 11 | + String[] st=new String[c+1]; |
| 12 | + String t=""; |
| 13 | + int j=0; |
| 14 | + for (int i=0;i<s.length();i++){ |
| 15 | + if(s.charAt(i)!=' '){ |
| 16 | + t += s.charAt(i); |
| 17 | + }else{ |
| 18 | + st[j++] = t; |
| 19 | + t = ""; |
| 20 | + } |
| 21 | + } |
| 22 | + st[j]=t; |
| 23 | + return st; |
| 24 | + } |
| 25 | + public static void main(String[] arg){ |
| 26 | + Scanner sc = new Scanner(System.in); |
| 27 | + System.out.println("Enter the String: "); |
| 28 | + String s = sc.nextLine(); |
| 29 | + String vow="aeiou"; |
| 30 | + String[] words=split(s); |
| 31 | + String t=""; |
| 32 | + int c=0; |
| 33 | + for(int i=0;i<words.length;i++){ |
| 34 | + t+=words[i]; |
| 35 | + for(int k=0;k<t.length();k++){ |
| 36 | + for(int j=0;j<vow.length();j++){ |
| 37 | + if(t.charAt(k)==vow.charAt(j)){ |
| 38 | + c++; |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + System.out.println(t+"="+c); |
| 43 | + t=""; c=0; |
| 44 | + } |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | + |
0 commit comments