Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P07_ChristmasTree {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. for (int row = 0; row < n + 1; row++) {
  9. String spaces = repeatStrr(" ", (n - row));
  10. String stars = repeatStrr("*", row);
  11.  
  12. String currentRow = spaces + stars + " | " + stars;
  13. System.out.println(currentRow);
  14.  
  15. }
  16.  
  17. }static String repeatStrr(String strToRepeat, int count) {
  18. String text = "";
  19. for (int i = 0; i < count; i++) {
  20. text += strToRepeat;
  21. }
  22. return text;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement