Advertisement
Guest User

ChristmasToy SoftUni

a guest
Feb 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasToy {
  4. static String repeatString(String strToRep, int count) {
  5. String text = "";
  6. for (int i = 0; i < count; i++) {
  7. text += strToRep;
  8. }
  9. return text;
  10. }
  11.  
  12. public static void main(String[] args) {
  13. Scanner scanner = new Scanner(System.in);
  14. int n = Integer.parseInt(scanner.nextLine());
  15.  
  16. String dashesFLrow = repeatString("-", 2 * n);
  17. String starsFLrow = repeatString("*", n);
  18. String FLrow = dashesFLrow + starsFLrow + dashesFLrow;
  19. System.out.println(FLrow);
  20. int a = 0;
  21. int x = 2;
  22. int y = 1;
  23. for (int row = 0; row < n / 2; row++) {
  24. String dashes = repeatString("-", (4 * n - 4) / 2 - a);
  25. String stars = repeatString("*", y);
  26. String symbol = repeatString("&", n + x);
  27. System.out.println(dashes + stars + symbol + stars + dashes);
  28. a += 2;
  29. x += 2;
  30. y++;
  31. }
  32. a = 1;
  33. x = 0;
  34. for (int row = 0; row < n / 2; row++) {
  35. String dashes = repeatString("-", n - a);
  36. String symbol = repeatString("~", 3*n-2+x);
  37. System.out.println(dashes+"**"+symbol+"**"+dashes);
  38. a++;
  39. x+=2;
  40. }
  41. a=0;
  42. x=0;
  43. String dashes = repeatString("-",n/2);
  44. String lines = repeatString("|",4*n-2);
  45. System.out.println(dashes+"*"+lines+"*"+dashes);
  46. for (int row = 0; row < n / 2; row++) {
  47. String dash = repeatString("-", n/2+a);
  48. String curls = repeatString("~",4*n-4-x);
  49. System.out.println(dash+"**"+curls+"**"+dash);
  50. a++;
  51. x+=2;
  52. }
  53. a=0;
  54. x=0;
  55. y=0;
  56. for (int row = 0; row < n / 2; row++) {
  57. String dash = repeatString("-",n+a);
  58. String star = repeatString("*", n/2-x);
  59. String symbol = repeatString("&",2*n-y );
  60. System.out.println(dash+star+symbol+star+dash);
  61. a+=2;
  62. x++;
  63. y+=2;
  64. }
  65. System.out.println(FLrow);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement