-
-
Save resarahadian/4125859 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[]) | |
{ | |
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"); | |
} //akhir switch case | |
lp.setPanjang(lp.panjang); | |
lp.setLebar(lp.lebar); | |
JOptionPane.showMessageDialog(null,"Hasil Luas Persegi adalah : " + lp.getLuas()); | |
} | |
} |
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 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