Question:
Java program for equilateral triangle inverted?
Code:
public class InvertedTriangle { public static void main (String[] args) { int height = 9; for(int i=0; i<=height; i++) { for(int j=0; j<i; j++) { System.out.print(" "); } int count = (height - i) * 2 + 1; for(int stars = 0; stars < count; stars++) { System.out.print("*"); } System.out.println(); } } }
Output:
$ java InvertedTriangle ******************* ***************** *************** ************* *********** ********* ******* ***** *** *