-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10820.java
More file actions
30 lines (29 loc) · 776 Bytes
/
10820.java
File metadata and controls
30 lines (29 loc) · 776 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
// 10820. 문자열 분석
// 2019.09.07
// 문자열 처리
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
String s = sc.nextLine();
int lower = 0; // 소문자
int upper = 0; // 대문자
int digit = 0; // 숫자
int space = 0; // 공백
for (int i = 0; i < s.length(); i++) {
if ('a' <= s.charAt(i) && s.charAt(i) <= 'z') {
lower++;
} else if ('A' <= s.charAt(i) && s.charAt(i) <= 'Z') {
upper++;
} else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') {
digit++;
} else if (s.charAt(i) == ' ') {
space++;
}
}
System.out.println(lower + " " + upper + " " + digit + " " + space);
}
sc.close();
}
}