-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathre_2015_NHN_03.java
More file actions
68 lines (53 loc) · 1.16 KB
/
re_2015_NHN_03.java
File metadata and controls
68 lines (53 loc) · 1.16 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
class Main {
public static boolean isVowel(String w) {
int cnt=0;
boolean check = false;
for(int i=0; i<w.length(); i++) {
if(w.charAt(i) == 'a' || w.charAt(i) == 'e' || w.charAt(i) == 'i' || w.charAt(i) == 'o' || w.charAt(i) == 'u') {
cnt++;
if(cnt>=2) {
check = true;
break;
}
} else {
cnt = 0;
}
}
return check;
}
public static boolean isConsonant(String w) {
int cnt = 0;
boolean check = false;
for(int i=0; i<w.length(); i++) {
if(w.charAt(i) == 'a' || w.charAt(i) == 'e' || w.charAt(i) == 'i' || w.charAt(i) == 'o' || w.charAt(i) == 'u') {
cnt = 0;
} else {
cnt++;
if(cnt>=3) {
check = true;
break;
}
}
}
return check;
}
public static void main(String[] args) {
String input;
Scanner sc = new Scanner(System.in);
input = sc.nextLine();
String[] words = input.split("\\s");
int cntVowel = 0;
int cntConsonant = 0;
for(String word : words) {
if(isVowel(word)) {
cntVowel++;
}
if(isConsonant(word)) {
cntConsonant++;
}
}
System.out.println(cntVowel);
System.out.println(cntConsonant);
}
}