// Draws triangular figures of stars using a parameterized method. public class Loops { public static void main(String[] args) { triangle(5); triangle(12); triangle(3); } // Draws a triangle figure of the given size. public static void triangle(int height) { for (int i = 1; i <= height; i++) { for (int j = 1; j <= i - 1; j++) { System.out.print(" "); } for (int j = 1; j <= (2 * height + 1) - 2 * i; j++) { System.out.print("*"); } System.out.println(); } } } /* output: ********* ******* ***** *** * *********************** ********************* ******************* ***************** *************** ************* *********** ********* ******* ***** *** * ***** *** * */