.: Java :. Membuat Jajar Genjang

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 jajar_genjang {

public static void main(String[] args) {
int n;
String input;
input=JOptionPane.showInputDialog(“Masukkan bilangan yang anda inginkan :”);
n=Integer.parseInt(input);

for(int x=1;x<=n;x++){
for(int y=n;y>=x;y–){
System.out.print(” “);
}
for(int y=1;y<=n;y++){
System.out.print(y+” “);
}
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