Berikut Hasil dan Source code-nya.
Class Main :
/**
*
*
* @author (Ismail Arifin)
* @version (10/09/2018)
*/
public class Main
{
public static void main(String args[])
{
kubus akubus;
akubus = new kubus();
akubus.s = 5;
double lpkubus = akubus.luasp();
double vkubus= akubus.volume();
System.out.println("Kubus");
System.out.println("Sisi = "+akubus.s);
System.out.println("Luas permukaan = "+lpkubus);
System.out.println("Volume = "+vkubus);
System.out.println();
balok abalok;
abalok = new balok();
abalok.p = 10;
abalok.l = 5;
abalok.t = 4;
double lpbalok = abalok.luasp();
double vbalok = abalok.volume();
System.out.println("Balok");
System.out.println("Panjang = "+abalok.p+" Lebar = "+abalok.l+" Tinggi = "+abalok.t);
System.out.println("Luas permukaan = "+lpbalok);
System.out.println("Volume = "+vbalok);
System.out.println();
Tabung aTabung;
aTabung = new Tabung();
aTabung.r = 5;
aTabung.t = 10;
double lptabung = aTabung.luasp();
double vtabung = aTabung.volume();
System.out.println("Tabung");
System.out.println("Jari-jari = "+aTabung.r+" Tinggi = "+aTabung.t);
System.out.println("Luas permukaan = "+lptabung);
System.out.println("Volume = "+vtabung);
System.out.println();
Bola aBola;
aBola = new Bola();
aBola.r = 7;
double lpbola = aBola.luasp();
double vbola = aBola.volume();
System.out.println("Bola");
System.out.println("Jari-jari = "+aBola.r);
System.out.println("Luas permukaan = "+lpbola);
System.out.println("Volume = "+vbola);
System.out.println();
}
}
Class Kubus :
/**
* Program implementasi kubus
*
* @author (Ismail Arifin)
* @version (10/09/2018)
*/
public class kubus
{
public double s;
public double luasp()
{
return 6*s*s;
}
public double volume()
{
return s*s*s;
}
}
Class Balok :
/**
* Program implementasi Balok
*
* @author (Ismail Arifin)
* @version (10/09/2018)
*/
public class balok
{
public double p, l, t;
public double luasp()
{
return 2*(p*l+p*t+l*t);
}
public double volume()
{
return p*l*t;
}
}
Class Tabung :
/**
* Program implementasi tabung
*
* @author (Ismail Arifin)
* @version (10/09/2018)
*/
public class Tabung
{
public double r, t;
public double luasp()
{
return 2*3.14*r*(r+t);
}
public double volume()
{
return 3.14*r*r*t;
}
}
Class Bola :
/**
* program implementasi bola
*
* @author (Ismail Arifin)
* @version (10/09/2018)
*/
public class Bola
{
public double r;
public double luasp()
{
return 4*3.14*r*r;
}
public double volume()
{
return 4/3*3*r*r*r;
}
}
Tidak ada komentar:
Posting Komentar