-
-
Save resarahadian/4144140 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
/* | |
* @ This program modify by resa cr | |
*/ | |
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[]) | |
{ | |
RumusPersegiPanjang RPP=new RumusPersegiPanjang(); | |
RumusPersegi RP=new RumusPersegi(); | |
RPP.setPanjang(RPP.panjang); | |
RPP.setLebar(RPP.lebar); | |
RP.setS1(RP.s1); | |
RP.setS2(RP.s2); | |
//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"); | |
System.out.println("2. Persegi"); | |
int hasil; | |
int hitung = Integer.parseInt(JOptionPane.showInputDialog("Pilih menu yang disediakan : ")); | |
switch(hitung) | |
{ | |
case 1 : | |
System.out.println("Anda memilih Persegi Panjang"); | |
RPP.panjang= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Panjang : ")); | |
RPP.lebar= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Lebar : ")); | |
JOptionPane.showMessageDialog(null,"Luas Persegi Panjang Adalah : " + RPP.getLuas()); | |
JOptionPane.showMessageDialog(null,"Keliling Persegi Panjang Adalah : " + RPP.getKeliling()); | |
break; //Setiap case diberi break untuk menghentikan proses yang sedang berlangsung | |
case 2: | |
System.out.println("Anda memilih Persegi"); | |
RP.s1= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Sisi 1 : ")); | |
RP.s2= Integer.parseInt(JOptionPane.showInputDialog("Masukkan Sisi 2 : ")); | |
JOptionPane.showMessageDialog(null,"Luas Persegi Adalah : " + RP.getLuasP()); | |
JOptionPane.showMessageDialog(null,"Luas Persegi Adalah : " + RP.getKelilingP()); | |
break; //Setiap case diberi break untuk menghentikan proses yang sedang berlangsung | |
default : | |
System.out.println("Pilihan tidak tersedia"); | |
} | |
} | |
} |
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
/* | |
* @ This program modify by resa cr | |
*/ | |
public class RumusPersegi | |
{ | |
int s1,s2,LuasP,KelilingP; | |
public int getS1() | |
{ | |
return s1; | |
} | |
public void setS1(int s1) | |
{ | |
this.s1=s1; | |
} | |
public int getS2() | |
{ | |
return s2; | |
} | |
public void setS2(int s2) | |
{ | |
this.s2=s2; | |
} | |
public int getLuasP() | |
{ | |
return getS1() * getS2(); | |
} | |
public int getKelilingP() | |
{ | |
return 4 * (getS1()+getS2()); | |
} | |
} | |
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
/* | |
* @ This program modify by resa cr | |
*/ | |
public class RumusPersegiPanjang | |
{ | |
int panjang,lebar,luas,keliling; | |
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(); | |
} | |
public int getKeliling() | |
{ | |
return 2*(getPanjang()+getLebar()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment