My homework this week involved using the for statement to create loops that would display triangles. The only output we're allowed to use are forms of the print statements... i.e. print(), println(). I've gotten my code to display the first 2 triangles I need, but I cannot manage to "invert" the triangles for the second part...
I need to create code that will make a triangle look like V
*********
*******
*****
***
**
*
using ( ' ' ) to produce x number of spaces before displaying the asterisks. my code for my working Triangle is
If someone could just help me get it turned around the right way I would appreciate it very very much.
I need to create code that will make a triangle look like V
*********
*******
*****
***
**
*
using ( ' ' ) to produce x number of spaces before displaying the asterisks. my code for my working Triangle is
Code:
public class Triangle
{
public static void main( String[] args ) {
for( int x=0; x<=10; x++ )
{
for( int y=10; y>=x; y-- ) {
System.out.print( "*" );
}
System.out.println( "" );
}
}
}
Comment