Vendrick-Xander

Challenge#1

Dec 16th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. package com.Suarez;
  2. /*
  3. Xander Fermier
  4. 12/13/18
  5. This is the program for the first challenge, mirrors. Generates a figure which has a variable size as declared by the constant SIZE
  6. */
  7. public class Challenge1 {
  8. public static final int SIZE = 6;
  9. public static void main(String [] args)
  10. {
  11. Line();
  12. Top();
  13. Bot();
  14. Line();
  15. Bot();
  16. Top();
  17. Line();
  18. }
  19. public static void Top()
  20. {
  21. for (int line=1; line <= SIZE; line++) {
  22. System.out.print("|");
  23. for (int space = 1; space <= SIZE - line + 1; space++) {
  24. System.out.print(" ");
  25. }
  26. for (int slash = 1; slash <= line - 1; slash++) {
  27. System.out.print("/");
  28. }
  29. System.out.print("*");
  30. for (int slashb = 1; slashb <= line - 1; slashb++) {
  31. System.out.print("\\");
  32. }
  33. for (int space = 1; space <= SIZE - line + 1; space++) {
  34. System.out.print(" ");
  35. }
  36. System.out.println("|");
  37. }
  38. }
  39. public static void Bot()
  40. {
  41. for(int line = 1; line <= SIZE; line++)
  42. {
  43. System.out.print("|");
  44. for (int space = 1; space <= line; space++)
  45. {
  46. System.out.print(" ");
  47. }
  48. for (int slashb = 1; slashb <= -line + SIZE; slashb++)
  49. {
  50. System.out.print("\\");
  51. }
  52. System.out.print("*");
  53. for (int slash = 1; slash <= -line+ SIZE; slash++)
  54. {
  55. System.out.print("/");
  56. }
  57. for (int space = 1; space <= line; space++)
  58. {
  59. System.out.print(" ");
  60. }
  61. System.out.println("|");
  62. }
  63. }
  64. public static void Line()
  65. {
  66. System.out.print("+");
  67. for (int dash = 1; dash <= SIZE*2+1; dash++)
  68. {
  69. System.out.print("-");
  70. }
  71. System.out.println("+");
  72. }
  73. }
Add Comment
Please, Sign In to add comment