-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem17.java
45 lines (36 loc) · 986 Bytes
/
Problem17.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package dimikOJ;
import java.util.Scanner;
public class Problem17 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int T = input.nextInt();
while (T < 1 || T > 100) {
T = input.nextInt();
}
String[] inputs = new String[T];
for (int i = 0; i < inputs.length; i++) {
String temp = input.nextLine();
int length = temp.length();
while (length < 1 || length > 1000) {
temp = input.nextLine();
length = temp.length();
}
inputs[i] = temp;
}
for (int i = 0; i < inputs.length; i++) {
System.out.println("Number of vowels = " + noOfVowel(inputs[i]));
}
}
public static int noOfVowel(String s) {
int vowels = 0;
s = s.toLowerCase();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
vowels++;
}
}
return vowels;
}
}