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.
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment