Script Bintang 7 (Pengulangan JAVA)


Bintang 7 edisi patah hati…….

Script Bintang 7

import javax.swing.JOptionPane;

public class Bintang7

{

public static void main (String [] args)

{

//mendeklarasikan variabel

int i;

int j;

int k;

int n;

n=Integer.parseInt(JOptionPane.showInputDialog(null,”bilangan = “));

//proses pengulangan

for (i=1 ; i<=(n-2) ; i++) {

for (j=(n-1); j >=(i); j–) {

System.out.print( ” “);

}

for (k=1;k <=((2*j)+1); k++) {

System.out.print(“*”);

}

System.out.print(“\n”);

}

for (i=1 ; i<=(n-3) ; i++) {

for (j=-1; j <=(i); j++) {

System.out.print(” “);

}

for (k=((2*(n-3))+(1)-i);k >=(j); k–) {

System.out.print(“*”);

}

System.out.print(“\n”);

}

//System.out.println(null,output,”Cetak bintang 1 – “+n+” dengan

FOR”, JOptionPane.INFORMATION_MESSAGE);

//terminasi program

System.exit (0);

}

}

3 thoughts on “Script Bintang 7 (Pengulangan JAVA)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s