Program Untuk Membuat Pola Piramida

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Program Untuk Membuat Pola Piramida as PDF for free.

More details

  • Words: 109
  • Pages: 1
/* 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"); } } }

Related Documents