Advertisement
YavorGrancharov

ChristmasHat

Feb 26th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasHat {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int n = Integer.parseInt(console.nextLine());
  7.  
  8.         int width = 4 * n + 1;
  9.         int height = 2 * n + 5;
  10.         int dots = n * 2 -1;
  11.         int dashes = 1;
  12.         dots--;
  13.  
  14.         System.out.println(repeatStr(".", n * 2 - 1) + "/" + "|" + "\\" + repeatStr(".", n * 2 - 1));
  15.         System.out.println(repeatStr(".", n * 2 - 1) + "\\" + "|" + "/" + repeatStr(".", n * 2 - 1));
  16.         System.out.println(repeatStr(".", n * 2 - 1) + "***" + repeatStr(".", n * 2 - 1));
  17.  
  18.         for (int i = 0; i < n * 2 - 1; i++) {
  19.             System.out.println(repeatStr(".", dots) + "*" + repeatStr("-", dashes) + "*" + repeatStr("-", dashes) + "*" + repeatStr(".", dots));
  20.             dots--;
  21.             dashes++;
  22.         }
  23.         System.out.println(repeatStr("*", width));
  24.         System.out.println(repeatStr("*.", width / 2) + "*");
  25.         System.out.println(repeatStr("*", width));
  26.     }
  27.     static String repeatStr(String str, int count) {
  28.         StringBuilder repeated = new StringBuilder();
  29.         for (int i = 0; i < count; i++) {
  30.             repeated.append(str);
  31.         }
  32.         return repeated.toString();
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement