Advertisement
zainarfi00

Chapter 2 Excersices

Sep 20th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. Zain Arfi
  2. Chapter 2 Exercises
  3.  
  4. Page 130 Number 16
  5. public class Pg130_16
  6. {
  7. public static void main(String[] args)
  8. {
  9. for(int row=1; row<=6; row++)
  10. {
  11. for(int bs=1; bs<=(row*2-2); bs++)
  12. {
  13. System.out.println("\\");
  14. }
  15. for(int exc=1; exc<=(row*2-2); exc--)
  16. {
  17. System.out.println("!");
  18. }
  19. for(int fs=1; fs<=(row*2-2); fs++)
  20. {
  21. System.out.println("/");
  22. }
  23. System.out.println();
  24. }
  25. }
  26. }
  27.  
  28. Page 131 20
  29. public class StarFigure
  30. {
  31. public static void main(String[] args)
  32. {
  33. for(int row=1; row<=4; row++)
  34. {
  35. for(int bs=1; bs<=(row*-4+20); bs++)
  36. {
  37. System.out.println("/");
  38. }
  39. for(int aster=1; aster<=(row*8-8); aster++)
  40. {
  41. System.out.print("*");
  42. }
  43. for(int fs=1; fs<=row*-4+20; fs++)
  44. {
  45. System.out.print("\\");
  46. }
  47. System.out.println();
  48. }
  49. }
  50. }
  51.  
  52. Pg 131 22
  53. public class Pg130_14
  54. {
  55. public static void main(String[] args)
  56. {
  57.  
  58. for(int row=1; row<=7; row++)
  59. {
  60. for(int star=row; star<=(row*2-2); row++)
  61. {
  62. System.out.println("*");
  63. }
  64. for(int money=row; money>=7; money--)
  65. {
  66. System.out.print("$");
  67. }
  68. for(int star2=row*2; star>=(row*7-2);star2++)
  69. {
  70. System.out.print("*");
  71. }
  72. for(int money=row; money>=7; money--)
  73. {
  74. System.out.print("$");
  75. }
  76. for(int star=row; star<=(row*2-2); row++)
  77. {
  78. System.out.println("*");
  79. }
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement