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