Bintang 6 With Java


Bintang6

Kemarin sintax Bintang7 edisi patah hati,sekarang mari berhitung mundur ke bintang6

import javax.swing.JOptionPane;

public class Bintang6

{

public static void main (String [] args)

{

//mendeklarasikan variabel

int i;

int j;

int n;

int k;

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

//proses pengulangan

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

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

System.out.print(” “);

}

for (k=((2*n)+(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);

}

}

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