veronikaaa86

Square Of Stars

Sep 11th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SquareOfStars1 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int n = Integer.parseInt(scan.nextLine());
  7.         String stars = new String(new char[n]).replace("\0", "*");
  8.         System.out.println(stars);
  9.         for (int i=0; i<n - 2; i++) {
  10.             System.out.printf("*");
  11.             System.out.printf(new String(new char[n - 2]).replace("\0", " "));
  12.             System.out.println("*");
  13.         }
  14.         System.out.println(stars);
  15.     }
  16. }
Add Comment
Please, Sign In to add comment