My program is correct except for that in the end, the program must output two \n\n. Just like that. Only on the last line, however. At every ten sets, it should only output one \n. THis is what the program should look like:
1 2 0 1 5 0 1 8 0 2 1 0 2 4 0 2 7 0 3 0 0 3 3 0 3 6 0 3 9 0 \n 4 2 0 4 5 0 4 8 0 5 1 0 5 4 0 5 7 0 6 0 0 6 3 0 6 6 0 6 9 0 \n 7 2 0 7 5 0 7 8 0 8 1 0 8 4 0 8 7 0 9 0 0 9 3 0 9 6 0 9 9 0 \n \n
This is my code.
import java.util.Scanner;
public class Exercise4_10 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int count = 1;
for (int i = 100; i <= 1000; i++) {
if (i%5==0 && i%6==0)
System.out.print((count++ % 10 != 0) ? i + " ": i + "\n" );
}
}
}
add this before the closing brace for main: