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