The program seems to do what's required, but it still isn't accepted. I can't pass the third, fourth, or fifth requirements.
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 {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> list1 = new ArrayList<Integer>();
ArrayList<Integer> list2 = new ArrayList<Integer>();
ArrayList<Integer> list3 = new ArrayList<Integer>();
// Get 20 strings from the keyboard
for(int x = 1; x <= 20; x++){
int y = Integer.parseInt(reader.readLine());
list.add(y);
if (x % 3 == 0 && x % 2 == 0){ // Check that the remainder is zero when divided by 3 and 2
list1.add(y); // Add to list1
list2.add(y); // Add to list2
}
else if (x % 3 == 0) // Check that the remainder is zero when we divide by three
list1.add(y); // Add to list1
else if(x % 2 == 0) // Check that the remainder is zero when we divide by two
list2.add(y); // Add to list2
else // All other numbers go to list4
list3.add(y);
}
printList(list1);
printList(list2);
printList(list3);
}
public static void printList(List<Integer> list) {
//write your code here
for(int x = 0; x < list.size(); x++){
System.out.println(list.get(x));
}
}
}