Koding JAVA : input dari keyboard untuk mendapatkan luas persegi

public static void main(String []args ) {

BufferedReader dataIn = new BufferedReader(new
InputStreamReader( System.in) );

String panjang, lebar = ” “;
int p=0, l=0;

try{
System.out.print(“Masukkan panjang: “);
panjang = dataIn.readLine();
p = Integer.parseInt(panjang);

System.out.print(“Masukkan lebar: “);
lebar = dataIn.readLine();
l = Integer.parseInt(lebar);

}catch( IOException e ){
System.out.println(“Error!”);
}
System.out.println(“Luas = ” + (p * l)  );
}
}

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