-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask6_1.java
More file actions
35 lines (30 loc) · 1.24 KB
/
Task6_1.java
File metadata and controls
35 lines (30 loc) · 1.24 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
import java.util.*;
import static utils.LineSeparator.*;
public class Task6_1 {
private static List<Integer> DIGITS = new ArrayList<>();
public static void main(String[] args) {
for (String argument : args) {
DIGITS.add(Integer.parseInt(argument));
}
System.out.print("Your digits: " + Arrays.toString(args) + ";" + lineSeparator());
digitCheck();
}
private static void digitCheck() {
SortedSet<Integer> unpaired = new TreeSet<>();
SortedSet<Integer> pair = new TreeSet<>();
Set<Integer> canNotDeterminate = new HashSet<>();
for (Integer integer = 0; integer < DIGITS.size(); integer++) {
if (DIGITS.get(integer) % 2 == 0 && DIGITS.get(integer) != 0) {
pair.add(DIGITS.get(integer));
} else if (DIGITS.get(integer) % 2 != 0) {
unpaired.add(DIGITS.get(integer));
}
else if (DIGITS.get(integer) == 0) {
canNotDeterminate.add(DIGITS.get(integer));
}
}
System.out.println("Unpaired digits: " + unpaired + ";");
System.out.println("Pair Digits:" + pair + ";");
System.out.println("Can not Determinate:" + canNotDeterminate + ";");
}
}