Contoh program java membuat Bintang membentuk ketupat

skali lagi saya share gan tugas tugas kuliah ane….

semoga bermanfaat untuk anda semua…. monggo copas aj gan….


import java.io.*;
class bintang
{
public static void main (String [] args) throws Exception
{
DataInputStream input=new DataInputStream(System.in);
int m,x,y,n;

System.out.println("--------------------------------------------------");
System.out.println("Nama : IRZIQ UHSI AMDIKEN");
System.out.println("NPM  : 06.2009.1.04802");
System.out.println("--------------------------------------------------");
System.out.print("inputkan jumlah baris : ");
int br=Integer.parseInt(input.readLine());
for (int i=1;i<=br;i++)
{
if (i <=4) {
for (int j=1;j<=br;j++)
{
if (j<=4)
{
m=i+j;
if (5<=m)
System.out.print ("*");
else
System.out.print (" ");
}
else
{
x=j-3;
if(x<=i)
System.out.print ("*");
else
System.out.print (" ");
}
}
}
else
{
for (int j=1;j<=br;j++)
{
if (j<=4)
{
y=i-3;
if (y<=j)
System.out.print ("*");
else
System.out.print (" ");
}
else
{
x=j-3; y=i-3; n=x+y;
if(n<=5)
System.out.print ("*");
else
System.out.print (" ");
}
}
}
System.out.println ();
}
}
}

ini gan hasilnya…..selamat mengerjakan dan semoga berhasil….

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