Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Demos;
- import java.util.Scanner;
- public class DemoClass {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- for (int i = 0; i < n; i++) {
- System.out.println(String.format("%s**%s",
- repeat("-", n + 2),
- repeat("-", n + 2)));
- }
- for (int i = 0; i < n - 3; i++) {
- System.out.println(String.format("%s****%s",
- repeat("-", n + 1),
- repeat("-", n + 1)));
- }
- System.out.println(String.format("%s******%s",
- repeat("-", n),
- repeat("-", n)));
- for (int i = 0; i < n - 4; i++) {
- System.out.println(String.format("%s**--**%s",
- repeat("-", n),
- repeat("-", n)));
- }
- for (int i = 0; i < n - 3; i++) {
- System.out.println(String.format("%s**----**%s",
- repeat("-", n - 1),
- repeat("-", n - 1)));
- }
- System.out.println(String.format("%s**********%s",
- repeat("-", n - 2),
- repeat("-", n - 2)));
- for (int i = 0; i < n - 3; i++) {
- System.out.println(String.format("%s**%s**%s",
- repeat("-", n - 3 - i),
- repeat("-", 8 + 2 * i),
- repeat("-", n - 3 - i)));
- }
- System.out.println(String.format("***%s***",
- repeat("-", n * 2)));
- }
- static String repeat(String strToRepeat, int count) {
- StringBuilder text = new StringBuilder();
- for (int i = 0; i < count; i++) {
- text.append(strToRepeat);
- }
- return text.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement