/** * This program draws a triangle of *s to standard output * * @author Stuart Hansen * @version October 23, 2002 */ import java.util.*; public class Triangles { // The main gets the number of rows and then draws the triangle public static void main (String [] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of rows: "); int rows = input.nextInt(); // This method draws the triangle for (int i=1; i<=rows; i++) { for (int j=1; j<=i; j++) { System.out.print("*"); } System.out.println(); } } }