SHARE
TWEET

Square Of Stars1

veronikaaa86 Jan 10th, 2018 (edited) 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SquareOfStars2 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         String star = "*";
  10.         for (int col = 0; col < 1; col++) {
  11.             for (int row = 0; row < n; row++) {
  12.                 System.out.print(star);
  13.             }
  14.             System.out.println();
  15.         }
  16.         for (int i = 0; i < n - 2; i++) {
  17.             System.out.print(star);
  18.             for (int j = 0; j < n - 2; j++) {
  19.                 System.out.print(" ");
  20.             }
  21.             System.out.println(star);
  22.         }
  23.         for (int col = 0; col < 1; col++) {
  24.             for (int row = 0; row < n; row++) {
  25.                 System.out.print(star);
  26.             }
  27.         }
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top