Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2012 15:30
Show Gist options
  • Save anonymous/4125450 to your computer and use it in GitHub Desktop.
Save anonymous/4125450 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import javax.Swing.JOptionPane;
public class HitungLuasBangun{
public static void main(String args[]){
LuasPersegi lp=new LuasPersegi();
//BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("=======================================");
System.out.println("Aplikasi Penghitungan Luas Bangun Datar" + "\n" + "Powered : OpenJDK");
System.out.println("=======================================");
System.out.println("Pilihan Menu : ");
System.out.println("1. Persegi Panjang");
int hasil;
int hitung = Integer.parseInt(JOptionPane.showInputDialog("Pilih menu yang disediakan : "));
switch(hitung)
{
case 1 :
System.out.println("Anda memilih Persegi Panjang");
lp.panjang= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Panjang : "));
lp.lebar= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Lebar : "));
break; //Setiap case diberi break untuk menghentikan proses yang sedang berlangsung
default :
System.out.println("Pilihan tidak tersedia");
}
lp.setPanjang(lp.panjang);
lp.setLebar(lp.lebar);
lp.getLuas=JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
}
}
public class LuasPersegi{
int panjang,lebar,luas;
public int getPanjang(){
return panjang;
}
public void setPanjang(int panjang){
this.panjang=panjang;
}
public int getLebar(){
return lebar;
}
public void setLebar(int lebar){
this.lebar=lebar;
}
public int getLuas(){
return getPanjang()*getLebar();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment