I have to make an X-shaped matrix using only numbers 9 and 1 where the number 1 is the one that has to form the X. The user chooses the size of the matrix, I have a bit of the script where I have problems in the for loops and when I run the program throws the 9's and 1's incomplete and the matrix is not well generated apart from that I can not achieve an X.
System.out.println("De que tamaño quiere el arreglo?.");
int cantidad = entrada.nextInt();
int[][]arreglo = new int[cantidad][cantidad];
for ( int i=0; i < arreglo.length ;i++){
for (int j=0; j<arreglo.length;j++){
if((i==j) || (i + j ==arreglo.length-1)){
arreglo[i][j] = 1;
System.out.print(arreglo[i][j] + "\t");
System.out.println();
}
else{
arreglo[i][j] = 9;
System.out.print(arreglo[i][j] + "\t");
System.out.println();