Advertisement
zainarfi00

Chapter 3 Projects

Oct 13th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /**
  2. *Chapter 3 Project Number 1
  3. *
  4. * ZAIN ARFI
  5. * VERSION 1
  6. */
  7. import java.util.*;
  8. public class Chp3_Project1
  9. {
  10. public static void main(String[] args)
  11. {
  12. Scanner console = new Scanner(System.in);
  13. System.out.println("How many segments would you like?");
  14. int segment = console.nextInt();
  15. System.out.println("How many rows would you like?");
  16. int height = console.nextInt();
  17. tree(segment, height);
  18. }
  19. public static int tree(int segment, int height)
  20. {
  21. return(
  22. for(int seg = 1; seg <= segment; seg++)
  23. {
  24. for(int row = 1; row <= height; row++)
  25. {
  26. for(int spaces = 1; spaces <= (row*-1+5); spaces++)
  27. {
  28. System.out.print(" ");
  29. }
  30. for(int stars = 1; stars <= (row*2-1); stars++)
  31. {
  32. System.out.print("*");
  33. }
  34. for(int spaces = 1; spaces <= (row*-1+5); spaces++)
  35. {
  36. System.out.print(" ");
  37. }
  38. System.out.println();
  39. }
  40. }
  41. );
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement