/** * COSC 1010 Triangle Demo * Demonstrates the use of nested loops to produce ASCII art triangles. * @author Dennis Brylow * @version 1.0,   2010 Sep 20 */ import java.util.Scanner; class Triangle { public static void main(String args[]) { System.out.println("Size?"); Scanner keyboard = new Scanner(System.in); int rows = keyboard.nextInt(); // Outer loop runs once for each row. for (int i = 0; i < rows; i++) { // Inner loop runs once for each column. for (int j = 0; j < i + 1; j++) { System.out.print(" *"); } System.out.println(); } } }