langsung aja ::
public class segitiga {
public static void main(String args[]){
String tinggi = "5";
int t = Integer.parseInt(tinggi);
for(int x=1;x<=t;x++){
for(int y=1;y<=x;y++){
System.out.print("*");
}
System.out.print("\n");
}
}
}
kalo mau yang gampang pake System.out.println("*****") jadinya:
System.out.println("*****")
System.out.println("****")
System.out.println("***")
System.out.println("**")
System.out.println("*")
kalo mau pake inputan pake bufferedreader jangan lupa import javaxswing-nya
Tidak ada komentar:
Posting Komentar