Tugas2.java
/*Tugas Algoritma Pemrograman
* Disma Ariyanti Widodo/11520241066
* Fatonah Dwi Putri/11520241043
* Soraya Mir'atun Miswah/11520241055
* Pendidikan Teknik Informatika/Kelas F
*/
//memanggil class Scanner
import java.util.Scanner;
//memanggil class
public class Tugas2 {
//method main
public static void main(String[] args) {
String c;
do{
int p;
System.out.print("Masukan Banyaknya baris -> ");
Scanner masuk = new Scanner(System.in);
p=masuk.nextInt();
int q=p;
int r=1;
int s=0;
while(s < p){
for (int z = 0; z < q-1; z++) {
System.out.print(" ");
}q--;
for (int z = 0; z < r; z++) {
System.out.print("*");
}r=r+2;
System.out.println("");
s++;
}
System.out.println("apakah anda ingin mengulang?(Ya/Tidak) ");
c=masuk.next();
}while (c.equalsIgnoreCase("y")||c.equalsIgnoreCase("Ya"));
}
}
Output :
Program Membuat Piramida Bintang |
2 Comments
bisakah di buat Piramid bolak balik gitu... ??? :D
ReplyDeletebisa kok, tanda nya dibalik aja :)
Delete