/* Program untuk membuat pola piramida * dengan * dan # secara berseling * author Faisal Fahmi */ import java.util.Scanner; public class Main{ public static void main (String[] args){ int a,b,c,d,e,y; System.out.print("---Program untuk membuat pola piramida---\n"); System.out.print("-----dengan * dan # secara berganti------\n\n"); //input banyak baris System.out.print("Masukkan nilai batas bilangan : "); Scanner batas = new Scanner (System.in); a = batas.nextInt(); //proses e=1;y = 0;c=0;b=0; for(c=(a-1);c>=b;c--) System.out.print(" "); System.out.print("* "); System.out.print("\n"); for (b=1;b
=b;c--) System.out.print(" "); for(c=b;c<=b;c++) System.out.print("* "); for (d=1;d<=b;d++) {e=e+1; y = e%2; if (y==0) System.out.print("# "); else System.out.print("* ");} for (d=b;d>=1;d--) { e=e+1; y = e%2; if (y==0) System.out.print("# "); else System.out.print("* ");} System.out.printf("\n"); } } }