Created
October 21, 2014 02:24
-
-
Save erikgunawan/4a775397434ffd30db7b to your computer and use it in GitHub Desktop.
Program Segitiga Asterisk (*) Menggunakan Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
/** | |
* @Developer : Erik Gunawan | |
* @Nickname : EXz | |
* @Phone : 0896 5332 0577 | |
* @EMail : admin@erikgunawan.com | |
* @Gmail : erik.gunawan44@gmail.com | |
* @Website : www.erikgunawan.com | |
* @Facebook : facebook.com/revolutionist.exz | |
* @Twitter : twitter.com/_EXz | |
*/ | |
public class SegitigaAsterisk { | |
private static BufferedReader br = null; | |
public static void main(String[] args) { | |
System.out.println("================================="); | |
System.out.println("Program Membuat Segitiga Asterisk"); | |
System.out.println("================================="); | |
System.out.println(); | |
boolean cek = true; | |
while (cek) { | |
br = new BufferedReader(new InputStreamReader(System.in)); | |
try { | |
System.out.print("Masukkan jumlah tingkat segitiga : "); | |
int jumlah = Integer.parseInt(br.readLine()); | |
for (int i=1; i<=jumlah; i++) { | |
for (int j=jumlah-i; j>0; j--) { | |
System.out.print(" "); | |
} | |
for (int j=0; j<i; j++) { | |
System.out.print(" *"); | |
} | |
System.out.println(); | |
} | |
System.out.print("Ingin coba lagi (Y/N) ? "); | |
String coba = br.readLine(); | |
if (coba.equalsIgnoreCase("N")) | |
cek = false; | |
else if (coba.equalsIgnoreCase("Y")) | |
cek = true; | |
else | |
System.exit(0); | |
System.out.println(); | |
} | |
catch (IOException ioe) { | |
System.out.println("Error IOException"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment