I can't complete the fourth "Requirements".
I don't know what I'm doing wrong.
If you enter an even number, it will be displayed as follows:
6
# # #
# # #
# # #
# # #
# # #
# # #
Odd number:
5
# # #
# #
# # #
# #
# # #
Could you help me identify what's causing this?
package en.codegym.task.jdk13.task06.task0634;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/*
Chess board
*/
public class Solution {
public static char[][] array;
public static void main(String[] args) {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input;
try {
input = Integer.parseInt(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
array = new char[input][input];
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array.length; j++) {
if (i % 2 == 0) {
if ( j % 2 == 0) {
array[i][j] = '#';
} else {
array[i][j] = ' ';
}
} else {
if ( j % 2 == 0) {
array[i][j] = ' ';
} else {
array[i][j] = '#';
}
}
}
}
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j]);
}
System.out.println();
}
System.out.println();
}
}