package com.codegym.task.task07.task0713;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Playing Javarella
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> three = new ArrayList<>();
ArrayList<Integer> two = new ArrayList<>();
ArrayList<Integer> other = new ArrayList<>();
for(int i = 0; i < 20; i++){
list.add(Integer.parseInt(reader.readLine()));
}
for(int i = 0; i < list.size(); i++){
Integer x = list.get(i);
if((x%3 == 0) && (x%2 == 0)) {
three.add(x);
two.add(x);
}
if(x%3 == 0) {
three.add(x);
}
if(x%2 == 0) {
two.add(x);
}
if((x%3 != 0) && (x%2 != 0)) {
other.add(x);
}
}
printList(three);
printList(two);
printList(other);
}
public static void printList(List<Integer> list) {
for(int i = 0; i < list.size(); i++){
System.out.println(list.get(i));
}
}
}
Can you help me with this? What is wrong with the code?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Misiu
14 March 2020, 23:38solution
Let it be number: 12.
You add it in the first, second and third if's. That is incorrect.
+2
Ted404
15 March 2020, 05:21
Great! Thank you Misiu!!!
0