/*
file name : Piramida Penuh Miring
programer : Andes Arinal G
deskripsi : 1.menggunakan For di Dalam for
*/
import javax.swing.JOptionPane;
public class PiramidaPenuhMiring
{
public static void main(String [] args)
{
int i,j;
String xS = JOptionPane.showInputDialog("Masukkan Nilai : ");
int x = Integer.parseInt(xS);
for(i=1; i<=x; i++)
{
for(j=1; j<=i; j++)
{
if ( (j+i )<=(x+1) )
{
System.out.print("*");
}
else
System.out.print( " ");
}
System.out.println("");
}
System.out.println("\n\n");
}
}
HASIL
Tidak ada komentar:
Posting Komentar