Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner key = new Scanner(System.in);
- System.out.print("Enter number for size of square n = ");
- int n = key.nextInt();
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n ; j++) {
- if (j == 1 || j == n || i == 1 || i == n ) {
- System.out.format("*");
- } else {
- System.out.format(" ");
- }
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement