- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
Latest commit
29 lines (25 loc) · 760 Bytes
/
Copy pathTest.java
File metadata and controls
29 lines (25 loc) · 760 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
importjava.io.FileInputStream;
importjava.io.FileNotFoundException;
importjava.io.InputStreamReader;
importjava.util.Scanner;
publicclassTest {
publicstaticvoidmain(String[] args) throwsFileNotFoundException {
Scanners = newScanner(newInputStreamReader(newFileInputStream("test.in")));
Strings1 = s.nextLine();
Strings2 = s.nextLine();
sum(s1);
sum(s2);
}
privatestaticvoidsum(Strings1) {
intsum = 0;
inti = 0;
while (i < s1.length()) {
charc = s1.charAt(i);
if (Character.isDigit(c)) {
sum += Integer.parseInt(Character.toString(c));
}
i++;
}
System.out.println(sum);
}
}