-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
29 lines (25 loc) · 760 Bytes
/
Test.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
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Test {
public static void main(String[] args) throws FileNotFoundException {
Scanner s = new Scanner(new InputStreamReader(new FileInputStream("test.in")));
String s1 = s.nextLine();
String s2 = s.nextLine();
sum(s1);
sum(s2);
}
private static void sum(String s1) {
int sum = 0;
int i = 0;
while (i < s1.length()) {
char c = s1.charAt(i);
if (Character.isDigit(c)) {
sum += Integer.parseInt(Character.toString(c));
}
i++;
}
System.out.println(sum);
}
}