Advertisement
dobby1498

Homework 9/9

Sep 15th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1.  
  2. /**
  3. * Homework 9/9
  4. *
  5. * Jackson Carroll
  6. */
  7. public class HW9_9
  8. {
  9. public static void main(String[]args)
  10. {
  11.  
  12. }
  13. public static void twentyTwo()
  14. {
  15. int total = 25;
  16. for (int number = 1; number <= (total/2); number++)
  17. {
  18. total = total - number;
  19. System.out.println(total + " " + number);
  20. }
  21. }
  22. public static void twentyFour()
  23. {
  24. for (int i = 1; i <= 3; i++)
  25. {
  26. System.out.println("How many lines");
  27. System.out.println("are printed?");
  28. }
  29. }
  30. public static void twentySix()
  31. {
  32. for(int i = 1; i <= 5; i++)
  33. {
  34. for (int j = 1; j <= 10; j++)
  35. {
  36. System.out.print((i * j) + " ");
  37. }
  38. System.out.println();
  39. }
  40. }
  41. public static void twentyEight()
  42. {
  43. for (int i = 1; i <= 2; i++)
  44. {
  45. for (int j = 1; j <= 3; j++)
  46. {
  47. for (int k = 1; k <= 4; k++)
  48. {
  49. System.out.print("*");
  50. }
  51. }
  52. System.out.print("!");
  53. System.out.println();
  54. }
  55. }
  56. public static void six()
  57. {
  58. int lineNumber = 1;
  59. for (lineNumber = 1; lineNumber <=7; lineNumber++)
  60. {
  61. for (int i = 1; i <= lineNumber; i++)
  62. {
  63. System.out.print(lineNumber);
  64. }
  65. System.out.println();
  66. }
  67. }
  68. public static void fifteen()
  69. {
  70. int num = 1;
  71. for (int lineNum = 1; lineNum <= 5; lineNum++)
  72. {
  73. for (int dash = 1; dash <= 6 - lineNum; dash++)
  74. {
  75. System.out.print("-");
  76. }
  77. for (int value = 1; value <= num; value++)
  78. {
  79. System.out.print(num);
  80. }
  81. for (int dash = 1; dash <= 6 - lineNum; dash++)
  82. {
  83. System.out.print("-");
  84. }
  85. System.out.println();
  86. num = num + 2;
  87. }
  88. }
  89. public static void twenty()
  90. {
  91. int num = 32;
  92. int slashCount = 1;
  93. for (int lineNum = 1; lineNum <= 5; lineNum = lineNum++)
  94. {
  95. for (int slash = 1; slash <= 17 - slashCount; slash++)
  96. {
  97. System.out.print("/");
  98. }
  99. for (int value = 32; value >= num; value--)
  100. {
  101. System.out.print("*");
  102. //i get an infinite loop of *'s when i run this code
  103. //and i have no idea why.
  104. }
  105. for (int slash = 1; slash <= 17 - slashCount; slash++)
  106. {
  107. System.out.print("\\");
  108. }
  109. System.out.println();
  110. num = num - 8;
  111. slashCount = slashCount + 4;
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement