Advertisement
Flaron

Udemy_26. DiagonalStar

Sep 14th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package lista.Alapok;
  2.  
  3. public class Main {
  4.  
  5. public static void printSquareStar(int number) {
  6. if (number<5) System.out.println("Invalid Value");
  7. else {
  8. int[][] array = new int[number][number];
  9. for (int i = 0; i < array.length; i++) {
  10. for (int j = 0; j < array.length; j++) {
  11. if ((i == 0 || i == number - 1) || (i == j) || (i + j == number - 1) || (j == 0 || j == number - 1))
  12. System.out.print("*");
  13.  
  14. else System.out.print(" ");
  15. }
  16. System.out.println();
  17. }
  18. }
  19. }
  20.  
  21. public static void main(String[] args) {
  22. printSquareStar(-8);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement