// // Triangle.java: a Java program to print a triangle on the screen // // Compare to traingle.cpp for hints on converting Java code to C++. // class Triangle { public static final int WIDTH = 8; public static final char FILL = '*'; public static void main(String[] args) { System.out.print("An "); System.out.print(WIDTH); System.out.println(" by " + WIDTH + " triangle:"); System.out.println(); for(int row = 1; row <= WIDTH; row++) { for(int col = 1; col <= row; col++) System.out.print(FILL); System.out.println(); } System.out.println(); System.out.println("Bye."); // note: no return (use System.exit(0) if exit code significant) } }