Exercises Instruction: Read each question carefully before providing an answer.
ID: 3830234 • Letter: E
Question
Exercises Instruction: Read each question carefully before providing an answer. A. Complete the implementation the Ellipsoid class that describes an el- lipsoid of Provide missing code segments A-J in a three-dimensional space. DO NOT rewrite code that is already given. Use descriptive names for variables where necessary. Use the Java library static constant Math.PI T. Definition: An ellipsoid is a surface that may be obtained from a sphere by deforming it by means of an affine transformation. See Figure 1. The volume and surface area of an ellipsoid can be calculated using the formulas below, where a, b and c are the elliptical radii volume wabc area 4m 1.6075 Figure 1: A Visual Depiction of an EllipsoidExplanation / Answer
Hi,Please find my implementation.
public class Ellipsoid {
private double a;
private double b;
private double c;
private static final double p = 1.6075;
public Ellipsoid() {
a = 1;
b = 1;
c = 1;
}
public Ellipsoid(double ra, double rb, double rc) {
a = ra;
b = rb;
c = rc;
}
public double getRadiusA(){
return a;
}
public double getRadiusB(){
return b;
}
public double getRadiusC(){
return c;
}
public void setEllipsoid(double ra, double rb, double rc){
a = ra;
b = rb;
c = rc;
}
public String toString() {
return "Ellipsois[a = "+a+", b = "+b+", c = "+c+"]";
}
public double area(){
double x = (Math.pow(a, p)*Math.pow(b, p) + Math.pow(b, p)*Math.pow(c, p) + Math.pow(c, p)*Math.pow(a, p))/3;
double area = 4*Math.PI*Math.pow(x, 1/p);
return area;
}
public double volume(){
return (4.0/3.0)*Math.PI*a*b*c;
}
public boolean equals(Ellipsoid obj) {
if(a==obj.a && b==obj.b && c==obj.c)
return true;
else
return false;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.