veronikaaa86

Crown1

Feb 20th, 2018
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. package DrawingWithLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Crown {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int width = (n * 2) - 1;
  12.         int height = (n  / 2) + 4;
  13.  
  14.         String firstLine = "@"
  15.                 + repeatString(" ", (width - 3) / 2)
  16.                 + "@"
  17.                 + repeatString(" ", (width - 3) / 2)
  18.                 + "@";
  19.         System.out.println(firstLine);
  20.         String secondLine = "**"
  21.                 + repeatString(" ", n - 3)
  22.                 + "*"
  23.                 + repeatString(" ", n - 3)
  24.                 + "**";
  25.         System.out.println(secondLine);
  26.  
  27.         for (int i = 0; i < height - 6; i++) {
  28.             String line = "*"
  29.                     + repeatString(".", 1 + i)
  30.                     + "*"
  31.                     + repeatString(" ", (n - 5) - i * 2)
  32.                     + "*"
  33.                     + repeatString(".", 1 + 2 * i)
  34.                     + "*"
  35.                     + repeatString(" ", (n - 5) - i * 2)
  36.                     + "*"
  37.                     + repeatString(".", 1 + i)
  38.                     + "*";
  39.             System.out.println(line);
  40.         }
  41.         System.out.println("*"
  42.                 + repeatString(".", n / 2 - 1)
  43.                 + "*"
  44.                 + repeatString(".", n - 3)
  45.                 + "*"
  46.                 + repeatString(".", n / 2 - 1)
  47.                 + "*");
  48.         System.out.println("*"
  49.         + repeatString(".", n / 2)
  50.         + repeatString("*", n / 2 - 2)
  51.         + "."
  52.         + repeatString("*", n / 2 - 2)
  53.         + repeatString(".", n / 2)
  54.         + "*");
  55.  
  56.         System.out.println(repeatString("*", width));
  57.         System.out.println(repeatString("*", width));
  58.  
  59.  
  60.     }
  61.  
  62.     public static String repeatString(String toRepeat, int count) {
  63.         String result = "";
  64.         for (int i = 0; i < count; i++) {
  65.             result += toRepeat;
  66.         }
  67.         return result;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment