Answer to Question #843 in Java | JSP | JSF for Dani

Question #843
I have to write a program so the user can input the size of a triangle, 1-50, and then output the triangle with asterisks. The user's input is the middle of the triangle. For example, if they input 3, it looks like this:
*
**
***
**
*
I need to use nested for loops. So far i did the for loop for the top of the triangle:
for(row = 1; row <= size; row++)
{
for(col = 1 ; col <= row ; col++)
{
System.out.print("*");
}
System.out.println();
}
Now i need to do the for loop for the bottom half and cannot figure it out.
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS