P
P
PRAIT2019-07-08 22:24:12
Java
PRAIT, 2019-07-08 22:24:12

How to draw an empty square with X inside?

Hi guys! You need to draw such a square
5d2397fabc965112357099.png
, 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(" ");
      }
    }
  }
}

5d239831b870e664314027.png
I do not understand how to make another line? Please give a hint, don't say the answer, I want to do it myself! I will be very grateful to you guys! Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aol-nnov, 2019-07-08
@aol-nnov

do not say the answer, I want to do it myself!

Please: manual account.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question