Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Programming Project 1 Chapter 3
- *
- * Hannah Kim
- * January 21, 2015
- */
- public class ProgrammingProject1
- {
- public static void main (String [] args)
- {
- int lines = 3;
- int segments = 4;
- tree(lines,segments);
- base(lines, segments);
- }
- public static void tree(int lines, int segments)
- {
- int maxspace = lines + segments - 1;
- for (int i = 1; i <= segments; i++)
- {
- for (int j = 1; j <= i + lines - 1; j++)
- {
- for (int spaces = 1; spaces <= maxspace - j; spaces++)
- {
- System.out.print(" ");
- }
- for (int stars = 1; stars <= 2 * j - 1; stars++)
- {
- System.out.print("*");
- }
- System.out.println();
- }
- }
- }
- public static void base(int lines, int segments)
- {
- int maxspace = lines + segments - 2 ;
- for (int i = 1; i <= 2; i++)
- {
- for (int j = 1; j <= maxspace; j++)
- {
- System.out.print(" ");
- }
- System.out.println("*");
- }
- for (int base = 1; base <= lines + segments - 5; base++)
- {
- System.out.print(" ");
- }
- System.out.print("*******");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement