Advertisement
paykova

ChristmasHat

Oct 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasHat {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.  
  10. String firstLine = repeatStr(".", 2*n - 1)
  11. +"/|\\"
  12. + repeatStr(".", 2*n - 1);
  13. System.out.println(firstLine);
  14.  
  15. String secondLine = repeatStr(".", 2*n - 1)
  16. +"\\|/"
  17. + repeatStr(".", 2*n - 1);
  18. System.out.println(secondLine);
  19.  
  20. for (int i = 0; i <2*n ; i++) {
  21. String body = repeatStr(".", 2*n - 1 - i)
  22. + "*"
  23. + repeatStr("-", i)
  24. + "*"
  25. + repeatStr("-", i)
  26. + "*"
  27. +repeatStr(".", 2*n - 1 - i);
  28. System.out.println(body);
  29.  
  30. }
  31. String staticLine1 = repeatStr("*", 4*n + 1);
  32. System.out.println(staticLine1);
  33. String staticLine2 = "*"
  34. + repeatStr(".*", 2*n);
  35. System.out.println(staticLine2);
  36. System.out.println(staticLine1);
  37.  
  38.  
  39.  
  40.  
  41. }
  42.  
  43. static String repeatStr(String strToRepeat, int count) {
  44. String text = "";
  45. for (int i = 0; i < count; i++) {
  46. text += strToRepeat;
  47. }
  48. return text;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement