Created
November 21, 2012 15:30
-
-
Save anonymous/4125450 to your computer and use it in GitHub Desktop.
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.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); | |
} | |
} |
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
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