Advertisement
skipter

Square Frame - Second decision / Easier

Apr 17th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(input.nextLine());
  10.  
  11.             System.out.println(("+ " + repeatStr("- ", n - 2) + "+"));
  12.             for (int j = 0; j < n - 2; j++) {
  13.                 System.out.println("| " + repeatStr("- ", n - 2) + "|");
  14.             }
  15.             System.out.print(("+ " + repeatStr("- ", n - 2) + "+"));
  16.             System.out.println();
  17.         }
  18.  
  19.  
  20.    public static String repeatStr(String repeatText, int counter) {
  21.         String text = "";
  22.        for (int i = 0; i < counter ; i++) {
  23.            text += repeatText;
  24.        }
  25.        return text;
  26.    }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement