The star figure

Report a typo

Your task is to draw a star on the n×n field using the symbols . and *. n is odd and doesn't exceed 15.

To do this, you can follow the instructions:

  • Firstly, you need to create a two-dimensional array (matrix) from n×n elements by filling it with the . symbols. Each element of the matrix is a string containing a single symbol.
  • Secondly, fill the middle row of the matrix, the middle column, and the diagonals with the * symbols. As a result, all *'s in the array must form the star figure.
  • Thirdly, output this matrix; elements of the array should be space-separated.

Sample Input 1:

9

Sample Output 1:

* . . . * . . . *
. * . . * . . * .
. . * . * . * . .
. . . * * * . . .
* * * * * * * * *
. . . * * * . . .
. . * . * . * . .
. * . . * . . * .
* . . . * . . . *
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic