Berikut saya cantumkan Codingan Main saya
Nama : Bobbi Aditya
NRP : 05111740000099
Kelas : PBO A
public class Main
{
public static void Main()
{
Circle aCircle;
aCircle= new Circle();
aCircle.r=100;
double Luas= aCircle.area();
double Keliling= aCircle.circumference();
System.out.println("Circle\nRadius="+aCircle.r+" Area="+Luas+" Circumference="+Keliling+"\n");
Triangle aTriangle;
aTriangle= new Triangle();
aTriangle.a=10;
aTriangle.t=7;
double LuasT= aTriangle.area();
double KelilingT= aTriangle.circumference();
System.out.println("Triangle\nAlas="+aTriangle.a+" Tinggi="+aTriangle.t+" Area="+LuasT+" Circumference="+KelilingT+"\n");
Square aSquare;
aSquare = new Square();
aSquare.s= 8;
double LuasS= aSquare.area();
double KelilingS= aSquare.circumference();
System.out.println("Square\nAlas="+aSquare.s+" Area="+LuasS+" Circumference="+KelilingS+"\n");
parallelogram aparallelogram;
aparallelogram= new parallelogram();
aparallelogram.a=10;
aparallelogram.t=7;
aparallelogram.s=8;
double LuasP= aparallelogram.area();
double KelilingP= aparallelogram.circumference();
System.out.println("Parallelogram\nAlas="+aparallelogram.a+" Tinggi="+aparallelogram.t+" Sisi Miring="+aparallelogram.s+" Area="+LuasP+" Circumference="+KelilingP+"\n");
Diamond aDiamond;
aDiamond= new Diamond();
aDiamond.d1=12;
aDiamond.d2=10;
aDiamond.s=8;
double LuasD= aDiamond.area();
double KelilingD= aDiamond.circumference();
System.out.println("Diamond\nDiagonal 1="+aDiamond.d1+" Diagonal 2="+aDiamond.d2+" Sisi Miring="+aDiamond.s+" Area="+LuasD+" Circumference="+KelilingD+"\n");
}
}
Berikut codingan fungsi Circle public class Circle
{
public double r;
public double circumference()
{
return 2 * 3.14 * r;
}
public double area()
{
return 3.14 * r * r;
}
}
Berikut codingan fungsi Triangle public class Triangle
{
public double a;
public double t;
public double circumference()
{
return 3 * a;
}
public double area()
{
return (a * t)/ 2;
}
}
Berikut codingan fungsi Square public class Square
{
public double s;
public double circumference()
{
return 4 * s;
}
public double area()
{
return s * s;
}
}
Berikut codingan fungsi Parallelorgram public class parallelogram
{
public double a;
public double t;
public double s;
public double circumference()
{
return (2*a)+(2*s);
}
public double area()
{
return a*t;
}
}
Berikut codingan fungsi diamond public class Diamond
{
public double d1;
public double d2;
public double s;
public double circumference()
{
return 4 * s;
}
public double area()
{
return (d1*d2)/2;
}
}
Hasil dari codingan tersebut adalahNama : Bobbi Aditya
NRP : 05111740000099
Kelas : PBO A
Comments
Post a Comment