Berikut codingannya ...
import javax.swing.*;
public class Segitiga1 {
public static void main(String[]args){
int a,b;
int tinggi=Integer.parseInt(JOptionPane.showInputDialog("Masukkan tinggi"));
for(a=1;a<=tinggi;a++){
for(b=1;b<=a;b++){
System.out.print("*");
}
System.out.println("");
}
}
}
Output :
*
**
***
****
*****
Tags:
Java