Answer the question
In order to leave comments, you need to log in
How to draw an empty square with X inside?
Hi guys! You need to draw such a square
, and here's what I got
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
try (Scanner tru = new Scanner(System.in)) {
int count = 10;
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
if (i == 0 || i == count - 1 || j == 0 || j == count - 1) {
System.out.print("*");
} else if (i == j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println(" ");
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question