Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tree {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- System.out.println("Enter the no. of treetop rows:");
- int rows = s.nextInt();
- for (int i = 1; i <= rows; i++) {
- for (int space = 0; space < rows - i; space++) {
- System.out.print(" ");
- }
- for (int j = 1; j <= 2 * i - 1; j++) {
- System.out.print("* ");
- }
- System.out.println();
- }
- for (int i = 0; i < 2; i++) {
- for (int space = 0; space < rows - 2; space++) {
- System.out.print(" ");
- }
- for (int j = 0; j < 3; j++) {
- System.out.print("* ");
- }
- System.out.println();
- }
- s.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement