Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ChristmasTree1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int spaces = n;
- for (int i = 0; i <= n; i++) {
- System.out.println(repeatString(" ", spaces) +
- repeatString("*", i) +
- " | " +
- repeatString("*", i));
- spaces--;
- }
- }
- static String repeatString(String toRepeat, int count) {
- StringBuilder text = new StringBuilder();
- for (int i = 1; i <=count; i++) {
- text.append(toRepeat);
- }
- return text.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement