Skip to content

Instantly share code, notes, and snippets.

Created November 19, 2012 16:12
Show Gist options
  • Save anonymous/4111525 to your computer and use it in GitHub Desktop.
Save anonymous/4111525 to your computer and use it in GitHub Desktop.
public class BangunDatar{
String persegi;
public String getPesegi(){
return persegi;
}
public void setPersegi(String persegi){
this.persegi=persegi;
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class HitungLuasBangun{
public static void main(String args[]){
LuasPersegi lp=new LuasPersegi();
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
try{
System.out.println("Masukan Panjang : ");
lp.panjang=br.readLine();
System.out.println("Masukan Panjang : ");
lp.lebar=br.readLine();
}
catch(IOException io){
System.out.println(io);
}
lp.setPanjang(lp.panjang);
lp.setLebar(lp.lebar);
System.out.println("_________________________");
System.out.println("Panjang : "+lp.getPanjang());
System.out.println("Lebar : "+lp.getLebar());
System.out.println("Luas : "+lp.getLuas());
public class LuasPersegi extends BangunDatar{
String panjang,lebar,luas;
public String getPanjang(){
return panjang;
}
public void setPanjang(String panjang){
this.panjang=panjang;
}
public String getLebar(){
return lebar;
}
public void setLebar(String lebar){
this.lebar=lebar;
}
public String getLuas(){
return luas;
}
public void setLuas(String luas){
return luas=panjang*lebar;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment