.: Java :. Membuat Segitiga Tumpul

package Bentuk;

import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Nurul C.
*/
public class segitiga_tumpul {
public static void main(String[] args) {

int n, m, angka;
angka = Integer.parseInt(JOptionPane.showInputDialog(“Masukkan deret bilangannya :”));
for (n=1;n<=angka;n++){
for (m=n;m>=1;m–){
System.out.print(” “);
}
for (m=1;m<=n;m++){
System.out.print(angka+” “);
}
System.out.print(“\n”);
}
}
}

Berikut hasil outputnya :

array

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s