Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SquareOfStars {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int num = input.nextInt();
- String a = "*";
- String b = " ";
- for (int i = 1; i <= num; i++) {
- System.out.print(a);
- }
- System.out.print('\n');
- for (int x = 1; x <= (num - 2); x++) {
- System.out.print(a);
- for (int y = 1; y <= (num - 2); y++) {
- System.out.print(b);
- }
- System.out.println(a);
- }
- for (int i = 1; i <= num; i++) {
- System.out.print(a);
- }
- System.out.print('\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement