36.6k views
1 vote
55 POINTS, IN JAVA

In this program, you need to make an upright tree that contains stars *. Your output should look like:
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *

Hint: You will need to create a variable that controls how far the * is from edge of the console. That variable should change size each iteration through the outer loop!

1 Answer

1 vote

public class JavaApplication82 {

public static void main(String[] args) {

for (int i = 1; i <= 9; i++){

for (int w = 0; w < i; w++){

System.out.print("*");

}

System.out.println("");

}

}

}

This works for me.

User Murali Kurapati
by
5.3k points