Advertisement
desislava_topuzakova

Untitled

Feb 24th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasToy1 {
  4. public static void main(String[] agrs) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. int width = 5 * n;
  9. int length = 2 * n + 3;
  10.  
  11. //first and last row
  12. String firstAndLastRow =
  13. repeatStr("-", 2 * n)
  14. + repeatStr("*", n)
  15. + repeatStr("-", 2 * n);
  16.  
  17. System.out.println(firstAndLastRow);
  18.  
  19. //bodyUp
  20. for (int i = 0; i < n / 2; i++) {
  21.  
  22. String upperPart1 = repeatStr("-", (2 * n - 2) - 2 * i)
  23. + repeatStr("*", 1 + i)
  24. + repeatStr("&", (n + 2) + 2 * i)
  25. + repeatStr("*", 1 + i)
  26. + repeatStr("-", (2 * n - 2) - 2 * i);
  27.  
  28. System.out.println(upperPart1);
  29. }
  30.  
  31. for (int i = 0; i < n / 2; i++) {
  32.  
  33. String upperPart2 = repeatStr("-", (n - 1) - i)
  34. + "**"
  35. + repeatStr("~", (3 * n - 2) + 2 * i)
  36. + "**"
  37. + repeatStr("-", (n - 1) - i);
  38.  
  39. System.out.println(upperPart2);
  40. }
  41. //middle row
  42. String middleRow =
  43. repeatStr("-", n / 2)
  44. + "*"
  45. + repeatStr("|", 4 * n - 2)
  46. + "*"
  47. + repeatStr("-", n / 2);
  48.  
  49. System.out.println(middleRow);
  50.  
  51. //bodyDown
  52. for (int i = 0; i < n / 2; i++) {
  53.  
  54. String downPart1 = repeatStr("-", (n / 2) + i)
  55. + "**"
  56. + repeatStr("~", (width - 4 - 2 * (n / 2)) - 2 * i)
  57. + "**"
  58. + repeatStr("-", (n / 2) + i);
  59.  
  60. System.out.println(downPart1);
  61.  
  62. }
  63.  
  64. for (int i = 0; i < n / 2; i++) {
  65.  
  66. String downPart2 = repeatStr("-", n + 2 * i)
  67. + repeatStr("*", (n / 2) - i)
  68. + repeatStr("&", (2 * n) - 2 * i)
  69. + repeatStr("*", (n / 2) - i)
  70. + repeatStr("-", n + 2 * i);
  71.  
  72. System.out.println(downPart2);
  73. }
  74. //lastRow
  75. System.out.println(firstAndLastRow);
  76. }
  77.  
  78. static String repeatStr(String str, int count) {
  79. String text = "";
  80. {
  81. for (int j = 0; j < count; j++) {
  82. text = text + str;
  83. }
  84.  
  85. }
  86. return text;
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement