Advertisement
Arush22

Untitled

Dec 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package com.Suarez;
  2. // Arush Adabala
  3. // 12/13/2018
  4. // This Program prints a series of back slashes and forward slashes. It creates Challenge 1.
  5.  
  6. public class ChallengeCopy {
  7.  
  8. public static final int SIZE = 4;
  9.  
  10. public static void main(String[] args)
  11. {
  12. BreakLine();
  13. Top();
  14. Bottom();
  15. BreakLine();
  16. Bottom();
  17. Top();
  18. BreakLine();
  19. }
  20. public static void BreakLine ()
  21. {
  22. System.out.print("+");
  23. for(int i=1;i<=2*SIZE+1;i++)
  24. {
  25. System.out.print("-");
  26. }
  27. System.out.println("+");
  28. }
  29. public static void Top () {
  30.  
  31. for (int interval = 1; interval <= SIZE; interval++)
  32. {
  33. System.out.print("|");
  34. space(interval);
  35. forwardSlash(interval);
  36. System.out.print("*");
  37. backSlash(interval);
  38. space(interval);
  39. System.out.println("|");
  40. }
  41. }
  42. public static void Bottom () {
  43.  
  44. for (int interval = SIZE; interval >= 1; interval--)
  45. {
  46. System.out.print("|");
  47. space(interval);
  48. backSlash(interval);
  49. System.out.print("*");
  50. forwardSlash(interval);
  51. space(interval);
  52. System.out.println("|");
  53. }
  54. }
  55. public static void space (int counter)
  56. {
  57. for (int space = SIZE-counter; space >= 0; space--) {
  58. System.out.print(" ");
  59. }
  60. }
  61. public static void forwardSlash (int counter)
  62. {
  63. for (int slash = SIZE-counter; slash <= SIZE-2; slash++) {
  64. System.out.print("/");
  65. }
  66. }
  67. public static void backSlash (int counter)
  68. {
  69. for (int slash = SIZE-counter; slash <= SIZE-2; slash++) {
  70. System.out.print("\\");
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement