Advertisement
YavorGrancharov

SquareOfStars

Dec 14th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class SquareOfStars {
  3. public static void main(String[] args) {
  4.  
  5.         Scanner input = new Scanner(System.in);
  6.         int num = input.nextInt();
  7.         String a = "*";
  8.         String b = " ";
  9.  
  10.         for (int i = 1; i <= num; i++) {
  11.             System.out.print(a);
  12.         }
  13.         System.out.print('\n');
  14.  
  15.  
  16.         for (int x = 1; x <= (num - 2); x++) {
  17.             System.out.print(a);
  18.  
  19.             for (int y = 1; y <= (num - 2); y++) {
  20.                 System.out.print(b);
  21.             }
  22.             System.out.println(a);
  23.         }
  24.  
  25.         for (int i = 1; i <= num; i++) {
  26.             System.out.print(a);
  27.         }
  28.         System.out.print('\n');
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement