English Alphabets (100 Marks)
Input Format
The first line of input consist of number of test cases, T.
Next T lines consist of strings.
Constraints
1<= T <=10
1<= |S| <=1000
Output Format
For each string print the number of vowels, number of consonants and the product of them space separately.Sample TestCase 1
InpuT
2
abcdefgh
zxcvbnm
Output
2 6 12
0 7
- import java.io.*;
- public class CandidateCode {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
String test = sc.nextLine();
int t = Integer.parseInt(test);
for(int i=1;i<=t;i++){
String s = sc.nextLine();
// System.out.println(s);
int v=0,c=0;
for(int j=0;j<s.length();j++){
if(s.charAt(j)=='a'||s.charAt(j)=='e'||s.charAt(j)=='i'||s.charAt(j)=='o'||s.charAt(j)=='u')
v++;
else
c++;
}
System.out.println(v+" "+c+" "+v*c);
}
}
}
Thanks
ReplyDeleteFor this solution