Image

Imagemgrjoe wrote in Imagejava_dev 😛determined

Triangle

Hey guys & girls :)
I am trying to make a star program which will output a neat triangle. Where if the user inputs "3" it will make a triangle with a length of 3, as seen below. Now I made a simple program that will print out something similar but it's missing the indents and what not. I can see where the measurments of the length, be it 3... the top needs to be spaced 2, then the next 1 then the last 0... how would I go about this? Thank you :)
JoeY
  *
 ***
*****


public class StarProgram
{
        public static void main (String[] args)
        {
                System.out.print("Enter a number: ");
                int max = SavitchIn.readLineInt();
                        for (int row = 1; row <= max; row++)
                        {
                        for (int star = 1; star <= row; star++)
                        System.out.print ("*");

                        System.out.println();
                        }
        }
}