Advertisement
willieshi232

Unit 1 Exercises

Sep 5th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. 2.
  2. /**
  3. *Homework problem pp 54-55 number 2
  4. *
  5. * @author William Shi
  6. * @version 9/5/2015 version #1)
  7. */
  8. public class Spikey
  9. {
  10. public static void main(String[] args)
  11. {
  12. System.out.println(" \\/") ;
  13. System.out.println(" \\\\//") ;
  14. System.out.println("\\\\\\///") ;
  15. System.out.println("///\\\\\\" );
  16. System.out.println(" //\\\\") ;
  17. System.out.println(" /\\") ;
  18. }
  19. }
  20. 4.
  21. /**
  22. * Homework Problem pp 54-55 #4
  23. *
  24. * @author William Shi
  25. * @version 9/5/2015 Version 1
  26. */
  27. public class Difference
  28. {
  29. public static void main(String [] args)
  30. {
  31. System.out.println("What is the difference between");
  32. System.out.println("a ' and \"? Or between a \" and a \\\"?");
  33. System.out.println();
  34. System.out.println("One is what we see when we're typing our program.\nThe other is what appears on the \"console\".");
  35. }
  36. }
  37. 6.
  38. /**
  39. * Homework Problem pp 54-55 #6
  40. *
  41. * @author William Shi
  42. * @version 9/5/2015
  43. */
  44. public class Meta
  45. {
  46. public static void main (String[] args)
  47. {
  48. System.out.println("A \"quoted\" String is \n'much' better if you learn \nthe rules of \"escape sequences.\"");
  49. System.out.println("Also, \"\" represents an empty String. \nDon't forget: use \\\" instead of \" ! \n' ' is not the same as \"");
  50.  
  51. }
  52. }
  53. 8./**
  54. * Homework problem pp54-55 #8
  55. *
  56. * @author William Shi
  57. * @version 9/5/2015 v1
  58. */
  59. public class Stewie2
  60. {
  61. public static void Victory()
  62. {
  63. System.out.println("|| Victory is mine! ||");
  64. System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
  65. }
  66.  
  67. public static void main(String[] args)
  68. {
  69. System.out.println("//////////////////////");
  70. Victory();
  71. Victory();
  72. Victory();
  73. Victory();
  74. Victory();
  75. }
  76. }
  77. 10. * Homework Problem pp54-55 #10
  78. *
  79. * @author William Shi
  80. * @version 9/15/2015
  81. */
  82. public class Egg2
  83. {
  84. public static void Topegg()
  85. {
  86. System.out.println(" _______");
  87. System.out.println(" / \\");
  88. System.out.println("/ \\");
  89. }
  90. public static void Middleegg()
  91. {
  92. System.out.println("_\"_'_\"_'_\"_");
  93. }
  94. public static void Bottomegg()
  95. {
  96. System.out.println("\\ /");
  97. System.out.println(" \\_______/");
  98. }
  99. public static void main(String[] args)
  100. {
  101. Topegg();
  102. Bottomegg();
  103. Middleegg();
  104. Topegg();
  105. Bottomegg();
  106. Middleegg();
  107. Bottomegg();
  108. Topegg();
  109. Middleegg();
  110. Bottomegg();
  111. }
  112. }
  113. 11./**
  114. * Homework Problem pp 56-57 #11
  115. *
  116. * @author William Shi
  117. * @version 9/5/2015
  118. */
  119. public class TwoRockets
  120. {
  121. public static void cone()
  122. {
  123. System.out.println(" /\\ /\\ ");
  124. System.out.println(" / \\ / \\");
  125. System.out.println(" / \\ / \\");
  126. }
  127. public static void box()
  128. {
  129. System.out.println("+------+ +------+");
  130. System.out.println("| | | |");
  131. System.out.println("| | | |");
  132. System.out.println("+------+ +------+");
  133. }
  134. public static void main(String[] args)
  135. {
  136. cone();
  137. box();
  138. System.out.println("|United| |United|");
  139. System.out.println("|States| |States|");
  140. box();
  141. cone();
  142.  
  143. }
  144. }
  145. 13./**
  146. * Homework Problem pp56-57 #13
  147. *
  148. * @author William Shi
  149. * @version 9/5/2015
  150. */
  151. public class StarFigures
  152. {
  153. public static void box()
  154. {
  155. System.out.println("*****");
  156. System.out.println("*****");
  157. }
  158. public static void x()
  159. {
  160. System.out.println(" * * ");
  161. System.out.println(" * ");
  162. System.out.println(" * * ");
  163. }
  164. public static void main(String[] args)
  165. {
  166. box();
  167. x();
  168. System.out.println("");
  169. System.out.println("");
  170. box();
  171. x();
  172. box();
  173. System.out.println("");
  174. System.out.println("");
  175. System.out.println(" * ");
  176. System.out.println(" * ");
  177. System.out.println(" * ");
  178. box();
  179. x();
  180. }
  181. }
  182. 14.
  183. /**
  184. * Homework problem 56-57 #14.
  185. *
  186. * @author William Shi
  187. * @version 9/5/2105
  188. */
  189. public class Lanterns
  190. {
  191. public static void trap()
  192. {
  193. System.out.println(" *****");
  194. System.out.println(" *********");
  195. System.out.println("*************");
  196. }
  197. public static void line()
  198. {
  199. System.out.println("* | | | | | *");
  200. }
  201. public static void main()
  202. {
  203. trap();
  204. System.out.println("");
  205. System.out.println("");
  206. trap();
  207. line();
  208. System.out.println("*************");
  209. trap();
  210. System.out.println("");
  211. System.out.println("");
  212. trap();
  213. System.out.println(" ***** ");
  214. line();
  215. line();
  216. System.out.println(" ***** ");
  217. System.out.println(" ***** ");
  218. }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement