I am trying to make the triangle I have made up side down. Tried many times, but I don\'t know how to do this.
The code I have know is:
public stati
import java.util.Scanner;
public class EquilateralTraingle {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int side = sc.nextInt();
constructEquTri(side);
}
private static void constructEquTri(int length) {
// loop for each line
for (int i = length; i > 0; i--) {
// loop for initial spaces in each line
for (int k = 0; k < length - i; k++) {
System.out.print(" ");
}
// loop for printing * in each line
for (int j = 0; j < i; j++) {
System.out.print("*");
System.out.print(" ");
}
System.out.println();
}
}
}
/*Output:
10
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
*/