Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Sunglasses {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String FirstAndLastRow = repeatStr("*", 2 * n) + repeatStr(" ", n) + repeatStr("*", 2 * n);
- System.out.println(FirstAndLastRow);
- for (int i = 0; i < n - 2; i++) {
- String Body = "*" + repeatStr("/", 2 * n - 2) + "*"
- + repeatStr(" ", n) + "*" + repeatStr("/", 2 * n - 2) + "*";
- if (i == (n - 1) / 2 - 1) {
- String BodyWithPipe = "*" + repeatStr("/", 2 * n - 2) + "*"
- + repeatStr("|", n) + "*" + repeatStr("/", 2 * n - 2) + "*";
- System.out.println(BodyWithPipe);
- } else {
- System.out.println(Body);
- }
- }
- System.out.println(FirstAndLastRow);
- }
- static String repeatStr(String str, int count) {
- String text = "";
- {
- for (int j = 0; j < count; j++) {
- text = text + str;
- }
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement