Statistical vowels
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 28600 Accepted Submission (s): 11843
Problem Description
Counts the number of times each vowel appears in a string.
Input
The input data first includes an integer n, indicating the number of test instances, followed by a string of n rows with a length not greater than 100.
Output
Output 5 rows for each test instance in the following format:
A: num1
E: num2
I: num3
O: num4
U: num5
Multiple test instances are separated by one blank line.
Note: There are no blank lines after the last output :)
Sample Input
2
Aeiou
My name is ignatius
Sample Output
A: 1
E: 1
I: 1
O: 1
U: 1
A: 2
E: 1
I: 3
O: 0
U: 1
import java.io.BufferedInputStream;import java.util.*;public class Main {public static void main(String[] args) {Scanner sc=new Scanner(new BufferedInputStream(System.in));int k=sc.nextInt();sc.nextLine();for(int i=0;i<k;i++){String s=sc.nextLine();int a[]=new int[5];for(int j=0;j<s.length();j++){if(s.charAt(j)=='a')a[0]++;else if(s.charAt(j)=='e')a[1]++;else if(s.charAt(j)=='i')a[2]++;else if(s.charAt(j)=='o')a[3]++;else if(s.charAt(j)=='u')a[4]++;}System.out.println("a:"+a[0]);System.out.println("e:"+a[1]);System.out.println("i:"+a[2]);System.out.println("o:"+a[3]);System.out.println("u:"+a[4]);if(i!=k-1) System.out.println();}}}