Inverted Equilatieral Triangle (Asterisks) - Not Equilateral :-(
My assignment is to write a program that asks for the number of lines and then prints an inverted equilateral triangle across the number of lines. As far as I can see this program isn't printing the spaces properly and thus it is printing a right angled triangle and I don't know why. Can anybody help?
Thanks in advance :)>-
Code :
public class TestCW
{
public static void main (String [] args)
{
System.out.println ("Enter number");
int input, var1, var2, var3;
input = KBInput.readInt();
for (var1 = input; var1 >= 0; var1 --)
{
System.out.println();
for (var2 = var1; var2 < var1; var2 ++)
{
System.out.print(" ");
}
for (var3 = (var1 * 2 - 1); var3 > 0; var3 --)
{
System.out.print("*");
}
}
}
}
Re: Inverted Equilatieral Triangle (Asterisks) - Not Equilateral :-(
Solved now, never mind :))