Pemrograman Java - Membuat Bintang

program membuat BINTANG di JAVA



import java.util.Scanner;
public class bintang {
public static void main(String[] args) {
                int i;
                int j;
                Scanner masukan = new Scanner(System.in);
                System.out.print("Masukkan batas bilangannya : ");
                int batas = masukan.nextInt();
                for(i=1;i<=batas;i++)
                {
                                for(j=1;j<=i;j++)
                                {
                                                System.out.print("*");
                                }
                                System.out.println();
                                }
               
System.out.println(" ");
                                for (i=batas; i>=1; i--)
                                {
                                                for (j=1; j<=i; j++)
                                {
                                System.out.print ("*");
                                }
                                                System.out.println ();   
                                }
System.out.println(" ");
                                for (i=1; i<=batas; i++)
{
for (j=1; j<=batas-i; j++)
                                {
                                System.out.print (" ");
                                }
                                                for (j=1; j<2*i; j++)
                                {
                                System.out.print ("*");
                                }
                                {
                                System.out.println (" ");
                                }
}
}
}

Output:
 

Komentar

Postingan populer dari blog ini

Interrupt driven I/O

List Linier (Linked list) Dan Variasinya_Struktur Data

Menghitung Jarak Jatuh Peluru (C++)