Advertisement
desislava_topuzakova

Christamas Tree

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