Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Daniel Lawson
- Java 1, Chapter 2
- Pg.130 14 - 17 all , pg. 131 20 - 22 all
- */
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 14
- /**
- * Created by Daniel on 3/11/2016.
- */
- public class Exercise14
- {
- public static void main (String[] args)
- {
- for (int lines = 1; lines <= 4; lines++)
- {
- for (int number = 9; number >= 1; number--)
- {
- for (int times = 1; times <= number; times++)
- {
- System.out.print(number);
- }
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 15
- /**
- * Created by Daniel on 3/11/2016.
- */
- public class Exercise15 {
- public static void main(String[] args) {
- printDesign();
- }
- public static void printDesign() {
- for (int lines = 1; lines <= 5; lines++) {
- for (int dashes = 1; dashes <= lines * -1 + 6; dashes++) {
- System.out.print("-");
- }
- for (int numbers = 1; numbers <= lines * 2 - 1; numbers++) {
- System.out.print((lines * 2) - 1);
- }
- for (int dashes = 1; dashes <= lines * -1 + 6; dashes++) {
- System.out.print("-");
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 16
- /**
- * Created by Daniel on 3/11/2016.
- */
- public class Exercise16SlashFigure
- {
- //22
- public static void main(String[] args)
- {
- for (int lines = 1; lines <=6;lines++)
- {
- for (int slash =1; slash <= (lines*2)-2;slash++){
- System.out.print("\\");
- }
- for(int points =1;points <= lines*-4+26;points++) {
- System.out.print("!");
- }
- for (int slash =1; slash <= (lines*2)-2;slash++) {
- System.out.print("/");
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 17
- /**
- * Created by Daniel on 3/11/2016.
- */
- public class Exercise17SlashFigure2
- {
- public static final int HEIGHT = 6;
- // change the value of HEIGHT to change the height
- public static void main(String[] args)
- {
- for (int lines = 1; lines <=HEIGHT;lines++)
- {
- for (int slash =1; slash <= (lines*2)-2;slash++){
- System.out.print("\\");
- }
- for(int points =1;points <= lines*-4 + HEIGHT*4 +2 ;points++) {
- System.out.print("!");
- }
- for (int slash =1; slash <= (lines*2)-2;slash++) {
- System.out.print("/");
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 20
- /**
- * Created by Daniel on 3/13/2016.
- */
- public class Exercise20StarFigure
- {
- public static void main (String[] args)
- {
- for (int line =1; line <= 5; line++){
- for (int slash = 1;slash <= line*-4 + 20;slash++ ){
- System.out.print("/");
- }
- for (int star =1; star<= line*8 - 8;star++){
- System.out.print("*");
- }
- for (int slash = 1;slash <= line*-4 + 20;slash++ ){
- System.out.print("\\");
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 21
- /**
- * Created by Daniel on 3/13/2016.
- */
- public class Exercise21StarFigure2
- {
- public static final int HEIGHT = 5;
- //change HEIGHT to change the height of the figure
- public static void main (String[] args)
- {
- for (int line =1; line <= HEIGHT; line++)
- {
- for (int slash = 1;slash <= line*-4 + HEIGHT *4;slash++ )
- {
- System.out.print("/");
- }
- for (int star =1; star<= line*8 - 8;star++){
- System.out.print("*");
- }
- for (int slash = 1;slash <= line*-4 + HEIGHT * 4;slash++ )
- {
- System.out.print("\\");
- }
- System.out.println();
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------------
- // Exercise 22
- /**
- * Created by Daniel on 3/13/2016.
- */
- public class Exercise22DollarFigure {
- public static void main (String[] Args){
- for (int lines = 1; lines <= 7; lines++)
- {
- for(int outsideStar = 1;outsideStar<= lines*2 -2;outsideStar++)
- {
- System.out.print("*");
- }
- for(int money =1;money<= lines*-1 + 8; money++)
- {
- System.out.print("$");
- }
- for(int insideStar =1; insideStar <= lines *-2 + 16;insideStar++)
- {
- System.out.print("*");
- }
- for(int money =1;money<= lines*-1 + 8; money++){
- System.out.print("$");
- }
- for(int outsideStar = 1;outsideStar<= lines*2 -2;outsideStar++)
- {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment