/**
*
* @author aris-sugi
*/
public class Balok {
int panjang;
int tingi;
int lebar;
double volume;
double keliling;
double luas;
public Balok(int panjang, int tingi, int lebar) {
this.panjang = panjang;
this.tingi = tingi;
this.lebar = lebar;
}
public void volume(){
System.out.println(" volume balok "+panjang*lebar*tingi+ " cm");
}
public void keliling(){
System.out.println(" keliling balok "+ (2*(panjang*lebar+panjang*tingi+lebar*tingi)));
}
public void luas_permukaan(){
System.out.println("luas permukaan balok "+(4*(panjang+lebar+tingi)));
}
public int getLebar() {
return lebar;
}
public void setLebar(int lebar) {
this.lebar = lebar;
}
public int getPanjang() {
return panjang;
}
public void setPanjang(int panjang) {
this.panjang = panjang;
}
public int getTingi() {
return tingi;
}
public void setTingi(int tingi) {
this.tingi = tingi;
}
public void lebar(){
volume = panjang*tingi*lebar ;
System.out.println("volume = "+ volume);
}
public void lebar(String a){
keliling=2*panjang*lebar+panjang*tingi+tingi+lebar ;
System.out.println("keliling"+keliling);
}
public void lebar(String a, String b){
luas=4*panjang+tingi+lebar;
System.out.println("luas"+luas);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Balok a=new Balok(12,8,6);
a.volume();
a.keliling();
a.luas_permukaan();
System.out.println(" lebar "+a.getLebar());
a.setLebar(14);
System.out.println(" lebar "+a.getLebar());
System.out.println("tinggi "+a.getTingi());
a.setTingi(10);
a.volume();
}
}
Posted by 21.54 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar