Created
November 19, 2012 16:12
-
-
Save anonymous/4111525 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
public class BangunDatar{ | |
String persegi; | |
public String getPesegi(){ | |
return persegi; | |
} | |
public void setPersegi(String persegi){ | |
this.persegi=persegi; | |
} | |
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; | |
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()); |
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 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