Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package Demos;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DemoClass {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scan.nextLine());      
  10.  
  11.         for (int i = 0; i < n; i++) {
  12.             System.out.println(String.format("%s**%s",
  13.                     repeat("-", n + 2),
  14.                     repeat("-", n + 2)));
  15.         }
  16.  
  17.         for (int i = 0; i < n - 3; i++) {
  18.             System.out.println(String.format("%s****%s",
  19.                     repeat("-", n + 1),
  20.                     repeat("-", n + 1)));
  21.         }
  22.  
  23.         System.out.println(String.format("%s******%s",
  24.                 repeat("-", n),
  25.                 repeat("-", n)));
  26.  
  27.         for (int i = 0; i < n - 4; i++) {
  28.             System.out.println(String.format("%s**--**%s",
  29.                     repeat("-", n),
  30.                     repeat("-", n)));
  31.         }
  32.  
  33.         for (int i = 0; i < n - 3; i++) {
  34.             System.out.println(String.format("%s**----**%s",
  35.                     repeat("-", n - 1),
  36.                     repeat("-", n - 1)));
  37.         }
  38.  
  39.         System.out.println(String.format("%s**********%s",
  40.                 repeat("-", n - 2),
  41.                 repeat("-", n - 2)));
  42.  
  43.         for (int i = 0; i < n - 3; i++) {
  44.             System.out.println(String.format("%s**%s**%s",
  45.                     repeat("-", n - 3 - i),
  46.                     repeat("-", 8 + 2 * i),
  47.                     repeat("-", n - 3 - i)));
  48.         }
  49.  
  50.         System.out.println(String.format("***%s***",
  51.                 repeat("-", n * 2)));
  52.     }
  53.  
  54.     static String repeat(String strToRepeat, int count) {
  55.         StringBuilder text = new StringBuilder();
  56.         for (int i = 0; i < count; i++) {
  57.             text.append(strToRepeat);
  58.         }
  59.         return text.toString();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement