Kali ini saya akan memposting program java bintang 6 , mungkin anda masih bingung maksudnya bintang 6 itu apa , dari sini saya akan berbagi ilmu kepada kalian semua..lihat script dibawah ini
package bintang6;
/**
*
* @author alit
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//public class tugas_bintang6
{
//public static void main (String[] args)
{
int baris,m,x,y,n;
for(int i=1; i<=7; i++)
{
if(i<=4)
{
for(int j=1; j<=7; 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<=7; 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();
}
}
}
}
}
silahkan copas script di atas trus masuk di Netbeans kalian . . .
== >> Keluaran program di atas adalah sebagai berikut :
SEMOGA BERMANFAAT
package bintang6;
/**
*
* @author alit
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//public class tugas_bintang6
{
//public static void main (String[] args)
{
int baris,m,x,y,n;
for(int i=1; i<=7; i++)
{
if(i<=4)
{
for(int j=1; j<=7; 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<=7; 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();
}
}
}
}
}
silahkan copas script di atas trus masuk di Netbeans kalian . . .
== >> Keluaran program di atas adalah sebagai berikut :
SEMOGA BERMANFAAT
Artikel Terkait:

2 komentar:
mantap gan tutor pemogramannya. Sukses follow #50. :)
thankz gan....
Posting Komentar