I wrote code for an assignment that will output 4 triangles, 1 next to the other. It uses the While and nested For loops. The problem is the output is ok for the 1st and 4th triangle but the 2nd and 3rd need to be mirror images of what the output is now. This is the code I have for the assignment:
public class Triangle
{
public static void main(String args[])
{
int k=1;
int m=11;
while ( k !=11 && m !=1 )
{
for ( int i=1; i<=k; i++ )
{
System.out.print ("*");
}
System.out.print(" ");
for ( int i=1; i+1<=m; i++)
{
System.out.print ("*");
}
System.out.print (" ");
for ( int i=1; i+1<=m; i++ )
{
System.out.print ("*");
}
System.out.print (" ");
for ( int i=1; i<=k; i++ )
{
System.out.print ("*");
}
System.out.println();
k++;
m--;
}
}
}
Thanks for your help. David