Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SquareFrame {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- // First row
- System.out.print("+");
- for (int symbol = 0; symbol < n -2 ; symbol++) {
- System.out.print(" -");
- }
- System.out.print(" +");
- // Middle part
- System.out.println();
- for (int row = 0; row < n -2 ; row++) {
- System.out.print("|");
- for (int symbol = 0; symbol < n -2 ; symbol++) {
- System.out.print(" -");
- }
- System.out.println(" |");
- }
- System.out.print("+");
- for (int symbol = 0; symbol < n -2 ; symbol++) {
- System.out.print(" -");
- }
- System.out.print(" +");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment