-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsecutive2vowels.java
More file actions
34 lines (22 loc) · 878 Bytes
/
Consecutive2vowels.java
File metadata and controls
34 lines (22 loc) · 878 Bytes
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
import java.util.*;
public class Consecutive2vowels {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String x = sc.nextLine().toLowerCase();
String[] y = x.split(" ");
int c = 0;
for (int i = 0; i < y.length; i++) {
for (int j = 1; j < y[i].length(); j++) { // start from 1 to avoid out of bound exception
if (isVowel(y[i].charAt(j)) && isVowel(y[i].charAt(j - 1))) { // check if the current and previous
// character are vowels
c++;
break;
}
}
}
System.out.println(c);
}
public static boolean isVowel(char c) {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
}