skipter icon

Square Frame - Second decision / Easier

skipter | PRO | 04/17/17 07:43:06 PM UTC | 0 ⭐ | 336 👁️ | Never ⏰ | []
Java |

730 B

|

None

|

0 👍

/

0 👎

import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner input = new Scanner(System.in);
 
        int n = Integer.parseInt(input.nextLine());
 
            System.out.println(("+ " + repeatStr("- ", n - 2) + "+"));
            for (int j = 0; j < n - 2; j++) {
                System.out.println("| " + repeatStr("- ", n - 2) + "|");
            }
            System.out.print(("+ " + repeatStr("- ", n - 2) + "+"));
            System.out.println();
        }
 
 
   public static String repeatStr(String repeatText, int counter) {
        String text = "";
       for (int i = 0; i < counter ; i++) {
           text += repeatText;
       }
       return text;
   }
}

Comments