Advertisement
dessislava_nik

Untitled

Jun 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasTree {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scan.nextLine());
  8.  
  9. //FirstRow
  10. System.out.println ( repeatStr(" ", n - 1 ) + "|");
  11.  
  12. //MiddlePart
  13.  
  14. for (int i =1; i <= n; i++) {
  15. System.out.println(repeatStr(" ", n-1)+
  16. repeatStr("*", i) +
  17. "|" +
  18. repeatStr("*", i));
  19. }
  20.  
  21. }
  22.  
  23.  
  24. static String repeatStr(String strToRepeat, int count) {
  25. String text = "";
  26.  
  27. for (int i = 0; i < count; i++) {
  28. text = text + strToRepeat;
  29.  
  30. }
  31. return text;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement