Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class demo5 {
- public static void main(String[] agrs) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- //first row
- String fisrtAndLastRow = repeatStr("-", 2 * n)
- + repeatStr("*", n)
- + repeatStr("-", 2 * n);
- System.out.println(fisrtAndLastRow);
- //Body upperPart
- for (int i = 0; i < n / 2; i++) {
- String bodyUpperPart1 = repeatStr("-", (2 * n - 2) - 2 * i)
- + repeatStr("*", 1 + i)
- + repeatStr("&", (n + 2) + 2 * i)
- + repeatStr("*", 1 + i)
- + repeatStr("-", (2 * n - 2) - 2 * i);
- System.out.println(bodyUpperPart1);
- }
- for (int i = 0; i < n / 2; i++) {
- String bodyUpperPart2 = repeatStr("-", n - 1 - i)
- + "**"
- + repeatStr("~", 3 * n - 2 + 2 * i)
- + "**"
- + repeatStr("-", n - 1 - i);
- System.out.println(bodyUpperPart2);
- }
- //middle row
- String middleRow = repeatStr("-", n / 2)
- + "*"
- + repeatStr("|", 4 * n - 2)
- + "*"
- + repeatStr("-", n / 2);
- System.out.println(middleRow);
- //Body down
- for (int i = 0; i < n / 2; i++) {
- String bodyDownPart1 = repeatStr("-", (n / 2) + i)
- + "**"
- + repeatStr("~", (4 * n - 4) - 2 * i)
- + "**"
- + repeatStr("-", (n / 2) + i);
- System.out.println(bodyDownPart1);
- }
- for (int i = 0; i < n / 2; i++) {
- String bodyDownPart2 = repeatStr("-", n + 2 * i)
- + repeatStr("*", n / 2 - i)
- + repeatStr("&", 2 * n - 2 * i)
- + repeatStr("*", n / 2 - i)
- + repeatStr("-", n + 2 * i);
- System.out.println(bodyDownPart2);
- }
- System.out.println(fisrtAndLastRow);
- }
- 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