-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ035.java
More file actions
48 lines (33 loc) · 1.06 KB
/
J035.java
File metadata and controls
48 lines (33 loc) · 1.06 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
// 생년월일을 분해해 숫자 만들기
import java.util.Scanner;
public class J035{
public static void main(String[] args){
J035 pStudio = new J035();
pStudio.J035();
}
public void J035(){
Scanner s = new Scanner(System.in);
String ymd;
int y = 0;
int m = 0;
int d = 0;
int total = 0;
ymd = s.nextLine();
for(int i = 0; i<4; i++)
y += Character.getNumericValue(ymd.charAt(i));
if(ymd.charAt(4)!='0'){
m += Character.getNumericValue(ymd.charAt(4)) * 10;
m += Character.getNumericValue(ymd.charAt(5));
}
else
m += Character.getNumericValue(ymd.charAt(5));
if(ymd.charAt(6)!='0'){
d += Character.getNumericValue(ymd.charAt(6)) * 10;
d += Character.getNumericValue(ymd.charAt(7));
}
else
d += Character.getNumericValue(ymd.charAt(7));
total = y + m + d;
System.out.printf("%d",total);
}
}