-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask6_3.java
More file actions
37 lines (32 loc) · 1.23 KB
/
Task6_3.java
File metadata and controls
37 lines (32 loc) · 1.23 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
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static utils.LineSeparator.*;
public class Task6_3 {
private static List<Integer> DIGITS = new ArrayList<>();
public static void main(String[] args) {
System.out.print("Your digits: " + Arrays.toString(args) + ";" + lineSeparator());
for (String argument : args) {
DIGITS.add(Integer.parseInt(argument));
}
counter();
}
private static void counter() {
List<Integer> dividedOnThree = new ArrayList<>();
List<Integer> dividedOnNine = new ArrayList<>();
List<Integer> canNotDeterminate = new ArrayList<>();
for (Integer digit : DIGITS) {
if (digit % 3 == 0 && digit != 0) {
dividedOnThree.add(digit);
}
if (digit % 9 == 0 && digit != 0) {
dividedOnNine.add(digit);
} else if (digit == 0) {
canNotDeterminate.add(digit);
System.out.println("Can not determinate digit: " + canNotDeterminate + ";");
}
}
System.out.println("Divided On Three: " + dividedOnThree + ";");
System.out.println("Divided On Nine: " + dividedOnNine + ";");
}
}