daniel_lawson9999

Daniel Lawson Java 1, Chapter Two Pg.130 14 - 17 all , pg.

Mar 13th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.87 KB | None | 0 0
  1. /*
  2. Daniel Lawson
  3. Java 1, Chapter 2
  4. Pg.130 14 - 17  all , pg. 131 20 - 22 all
  5. */
  6. ---------------------------------------------------------------------------------------------------------------------------------------
  7. // Exercise 14
  8. /**
  9.  * Created by Daniel on 3/11/2016.
  10.  */
  11. public class Exercise14
  12. {
  13.     public static void main (String[] args)
  14.     {
  15.         for (int lines = 1; lines <= 4; lines++)
  16.         {
  17.             for (int number = 9; number >= 1; number--)
  18.             {
  19.                 for (int times = 1; times <= number; times++)
  20.                 {
  21.                     System.out.print(number);
  22.                 }
  23.             }
  24.             System.out.println();
  25.         }
  26.  
  27.     }
  28.  
  29. }
  30. ---------------------------------------------------------------------------------------------------------------------------------------
  31. // Exercise 15
  32. /**
  33.  * Created by Daniel on 3/11/2016.
  34.  */
  35. public class Exercise15 {
  36.     public static void main(String[] args) {
  37.  
  38.         printDesign();
  39.     }
  40.  
  41.     public static void printDesign() {
  42.         for (int lines = 1; lines <= 5; lines++) {
  43.             for (int dashes = 1; dashes <= lines * -1 + 6; dashes++) {
  44.                 System.out.print("-");
  45.             }
  46.  
  47.             for (int numbers = 1; numbers <= lines * 2 - 1; numbers++) {
  48.                 System.out.print((lines * 2) - 1);
  49.             }
  50.  
  51.             for (int dashes = 1; dashes <= lines * -1 + 6; dashes++) {
  52.                 System.out.print("-");
  53.             }
  54.             System.out.println();
  55.         }
  56.     }
  57.  
  58.  
  59. }
  60. ---------------------------------------------------------------------------------------------------------------------------------------
  61. // Exercise 16
  62. /**
  63.  * Created by Daniel on 3/11/2016.
  64.  */
  65. public class Exercise16SlashFigure
  66. {
  67.     //22
  68.     public static void main(String[] args)
  69.     {
  70.         for (int lines = 1; lines <=6;lines++)
  71.         {
  72.             for (int slash =1; slash <= (lines*2)-2;slash++){
  73.                 System.out.print("\\");
  74.             }
  75.  
  76.             for(int points =1;points <= lines*-4+26;points++) {
  77.                 System.out.print("!");
  78.             }
  79.  
  80.             for (int slash =1; slash <= (lines*2)-2;slash++) {
  81.                 System.out.print("/");
  82.             }
  83.             System.out.println();
  84.         }
  85.     }
  86.  }
  87. ---------------------------------------------------------------------------------------------------------------------------------------
  88. // Exercise 17
  89. /**
  90.  * Created by Daniel on 3/11/2016.
  91.  */
  92. public class Exercise17SlashFigure2
  93. {
  94.     public static final int HEIGHT = 6;
  95.     // change the value of HEIGHT to change the height
  96.     public static void main(String[] args)
  97.     {
  98.         for (int lines = 1; lines <=HEIGHT;lines++)
  99.         {
  100.             for (int slash =1; slash <= (lines*2)-2;slash++){
  101.                 System.out.print("\\");
  102.             }
  103.  
  104.             for(int points =1;points <= lines*-4 + HEIGHT*4 +2 ;points++) {
  105.                 System.out.print("!");
  106.             }
  107.  
  108.             for (int slash =1; slash <= (lines*2)-2;slash++) {
  109.                 System.out.print("/");
  110.             }
  111.             System.out.println();
  112.         }
  113.     }
  114.  
  115. }
  116. ---------------------------------------------------------------------------------------------------------------------------------------
  117. // Exercise 20
  118. /**
  119.  * Created by Daniel on 3/13/2016.
  120.  */
  121. public class Exercise20StarFigure
  122. {
  123.     public static void main (String[] args)
  124.     {
  125.         for (int line =1; line <= 5; line++){
  126.  
  127.             for (int slash = 1;slash <= line*-4 + 20;slash++ ){
  128.                 System.out.print("/");
  129.             }
  130.             for (int star =1; star<= line*8 - 8;star++){
  131.                 System.out.print("*");
  132.             }
  133.             for (int slash = 1;slash <= line*-4 + 20;slash++ ){
  134.                 System.out.print("\\");
  135.             }
  136.             System.out.println();
  137.         }
  138.  
  139.  
  140.     }
  141.  
  142.  
  143. }
  144. ---------------------------------------------------------------------------------------------------------------------------------------
  145. // Exercise 21
  146. /**
  147.  * Created by Daniel on 3/13/2016.
  148.  */
  149. public class Exercise21StarFigure2
  150. {
  151.     public static final int HEIGHT = 5;
  152.     //change HEIGHT to change the height of the figure
  153.     public static void main (String[] args)
  154.     {
  155.  
  156.         for (int line =1; line <= HEIGHT; line++)
  157.         {
  158.  
  159.             for (int slash = 1;slash <= line*-4 + HEIGHT *4;slash++ )
  160.             {
  161.                 System.out.print("/");
  162.             }
  163.             for (int star =1; star<= line*8 - 8;star++){
  164.                 System.out.print("*");
  165.             }
  166.             for (int slash = 1;slash <= line*-4 + HEIGHT * 4;slash++ )
  167.             {
  168.                 System.out.print("\\");
  169.             }
  170.             System.out.println();
  171.         }
  172.  
  173.  
  174.     }
  175.  
  176.  
  177. }
  178. ---------------------------------------------------------------------------------------------------------------------------------------
  179. // Exercise 22
  180. /**
  181.  * Created by Daniel on 3/13/2016.
  182.  */
  183. public class Exercise22DollarFigure {
  184.  
  185.     public static void main (String[] Args){
  186.  
  187.         for (int lines = 1; lines <= 7; lines++)
  188.         {
  189.  
  190.             for(int outsideStar = 1;outsideStar<= lines*2 -2;outsideStar++)
  191.             {
  192.                 System.out.print("*");
  193.             }
  194.             for(int money =1;money<= lines*-1 + 8; money++)
  195.             {
  196.             System.out.print("$");
  197.             }
  198.             for(int insideStar =1; insideStar <= lines *-2 + 16;insideStar++)
  199.             {
  200.                 System.out.print("*");
  201.             }
  202.             for(int money =1;money<= lines*-1 + 8; money++){
  203.                 System.out.print("$");
  204.             }
  205.             for(int outsideStar = 1;outsideStar<= lines*2 -2;outsideStar++)
  206.             {
  207.                 System.out.print("*");
  208.             }
  209.             System.out.println();
  210.  
  211.         }
  212.     }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment