Berikut tugas Saya.
Main
/**
* Write a description of class myMain here.
*
* @author (Ghannie Wijaya)
* @version (1.0)
*/
public class myMain
{
public static void main(String args[])
{
//kubus
Kubus aKubus;
aKubus = new Kubus();
aKubus.x = 5.0;
double LP = aKubus.LuasPermukaan();
double V = aKubus.Volume();
System.out.println("KUBUS");
System.out.println("Sisi = "+aKubus.x);
System.out.println("Luas Permukaan = "+LP);
System.out.println("Volume = "+V);
System.out.println("==================================");
//balok
Balok aBalok;
aBalok = new Balok();
aBalok.x = 15.0;
aBalok.y = 5.0;
aBalok.z = 10.0;
LP = aBalok.LuasPermukaan();
V = aBalok.Volume();
System.out.println("BALOK");
System.out.println("Panjang = "+aBalok.x);
System.out.println("Lebar = "+aBalok.y);
System.out.println("Tinggi = "+aBalok.z);
System.out.println("Luas Permukaan = "+LP);
System.out.println("Volume = "+V);
System.out.println("==================================");
//tabung
Tabung aTabung;
aTabung = new Tabung();
aTabung.r = 10.0;
aTabung.x = 20.0;
LP = aTabung.LuasPermukaan();
V = aTabung.Volume();
System.out.println("TABUNG");
System.out.println("Radius = "+aTabung.r);
System.out.println("Tinggi = "+aTabung.x);
System.out.println("Luas Permukaan = "+LP);
System.out.println("Volume = "+V);
System.out.println("==================================");
//bola
Bola aBola;
aBola = new Bola();
aBola.r = 10.0;
LP = aBola.LuasPermukaan();
V = aBola.Volume();
System.out.println("BOLA");
System.out.println("Radius = "+aBola.r);
System.out.println("Luas Permukaan = "+LP);
System.out.println("Volume = "+V);
}
}
Kubus
/**
* Write a description of class Kubus here.
*
* @author (Ghannie Wijaya)
* @version (1.0)
*/
public class Kubus
{
public double x;
public double LuasPermukaan()
{
return 6*x*x;
}
public double Volume()
{
return x*x*x;
}
}
Balok
/**
* Write a description of class Balok here.
*
* @author (Ghannie Wijaya)
* @version (1.0)
*/
public class Balok
{
public double x,y,z;
public double LuasPermukaan()
{
return 2*(x*y)+2*(y*z)+2*(x*z);
}
public double Volume()
{
return x*y*z;
}
}
Tabung
/**
* Write a description of class Tabung here.
*
* @author (Ghannie Wijaya)
* @version (1.0)
*/
public class Tabung
{
public double r;
public double x;
public double LuasPermukaan()
{
return 2*3.14*r*(r+x);
}
public double Volume()
{
return 3.14*r*r*x;
}
}
Bola
/**
* Write a description of class Bola here.
*
* @author (Ghannie Wijaya)
* @version (1.0)
*/
public class Bola
{
public double r;
public double LuasPermukaan()
{
return 4*3.14*r*r;
}
public double Volume()
{
// put your code here
return (4*3.14*r*r*r)/3;
}
}
---
Tidak ada komentar:
Posting Komentar