Use a nested for-loop to print out the following:
Update 30/01/2009:
* * * * *
* * * *
* * *
* *
*
Since some of you have seeked Mr Eric's help to solve this problem, I will give the rest a clue on how to solve this. You need to use 3 for-loops in the solution like this:
for(int i=0; i<5; i++) {
for(...; ...; ...) {
System.out.print("...");
}
for(...; ...; ...) {
System.out.print("...");
}
System.out.println();
}To get a clearer picture, the triangle actually looks like:
* * * * *Where the Os are spaces :)
O * * * *
O O * * *
O O O * *
O O O O *
No comments:
Post a Comment