56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
public class Elipse
|
|
{
|
|
private double smallRadius;
|
|
private double largeRadius;
|
|
private static final double PI = 3.14159;
|
|
|
|
public Elipse(double smallRadius, double largeRadius)
|
|
{
|
|
this.smallRadius = smallRadius;
|
|
this.largeRadius = largeRadius;
|
|
}
|
|
public void setSmallRadius(double radius)
|
|
{
|
|
this.smallRadius = radius;
|
|
}
|
|
public double getSmallRadius()
|
|
{
|
|
return smallRadius;
|
|
}
|
|
public void setLargeRadius(double radius)
|
|
{
|
|
this.largeRadius = radius;
|
|
}
|
|
public double getLargeRadius()
|
|
{
|
|
return largeRadius;
|
|
}
|
|
public double area()
|
|
{
|
|
return PI * smallRadius * largeRadius;
|
|
}
|
|
public double circumference()
|
|
{
|
|
double a = smallRadius;
|
|
double b = largeRadius;
|
|
double h = (a - b) * (a - b) / ((a + b) * (a + b));
|
|
double leftside = PI * (smallRadius + largeRadius);
|
|
double rightside = 1 + (3 * h)/(10 + Math.sqrt(4 - 3 * h));
|
|
|
|
return leftside * rightside;
|
|
}
|
|
public void printArea()
|
|
{
|
|
System.out.println("Area of elipse");
|
|
System.out.println("Small Radius: " + smallRadius);
|
|
System.out.println("Large Radius: " + largeRadius);
|
|
System.out.println("Area: " + area());
|
|
}
|
|
public void printCircumference()
|
|
{
|
|
System.out.println("Circumference of elipse");
|
|
System.out.println("Small Radius: " + smallRadius);
|
|
System.out.println("Large Radius: " + largeRadius);
|
|
System.out.println("Circumference: " + circumference());
|
|
}
|
|
} |