Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by Jo on 2/18/2017.
- */
- public class ChristmasTree {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int treeSize = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i <= treeSize; i++) {
- System.out.print(draw(" ", treeSize - i));
- System.out.print(draw("*", i));
- System.out.print(" | ");
- System.out.print(draw("*", i));
- System.out.println();
- }
- }
- public static String draw(String str, int count) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < count; i++) {
- sb.append(str);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement