-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEllipse.java
37 lines (29 loc) · 939 Bytes
/
Ellipse.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package shapes;
import java.util.Scanner;
public class Ellipse implements ShapeIO {
private double major = 0, minor = 0;
public Ellipse() {}
@Override
public void getSideLengths(Scanner scanner) {
System.out.println("What is the major axis length?");
major = scanner.nextDouble();
System.out.println("What is the minor axis length?");
minor = scanner.nextDouble();
}
@Override
public double getArea() {
return Math.PI * major * minor;
}
@Override
public double getPerimeter() {
return Math.PI * (major + minor) *
(3 * (Math.pow(major - minor, 2)
/ (Math.pow(major + minor, 2)
* (Math.sqrt(
-3 * (Math.pow(major - minor, 2)
/ Math.pow(major + minor, 2))
+ 4)
+ 10)))
+ 1);
}
}