Calculate the area of any 2D Quadrilateral in java? (method)
in
Programming Questions
•
5 months ago
side lengths of the quadriliateral is a,b,c,d
I know how to get the Perimeter, but i don't know how to write the code for the area...
Do i just need the side lengths? or do i also need angles?
public class Quadrilateral
{
double a;
double b;
double c;
double d;
public Quadrilateral(){
a=0;
b=0;
c=0;
d=0;
}
public Quadrilateral (double q, double w, double e, double r){
a=q;
b=w;
c=e;
d=r;
}
public double getSideA(){
return a;
}
public double getSideB(){
return b;
}
return b;
}
public double getSideC(){
return c;
}
return c;
}
public double getSideD(){
return d;
}
return d;
}
public void setSideA(double q){
a=q;
}
a=q;
}
public void setSideB(double w){
b=w;
}
b=w;
}
public void setSideD(double r){
d=r;
}
d=r;
}
public void setSideA(double q){
a=q;
}
a=q;
}
public double Perimeter(double p){
p=a+b+c+d;
return p;
}
p=a+b+c+d;
return p;
}
public double Area(){
return
}
public String toString(){
return "Sides: " + a + b + c + d ;
}
return
}
public String toString(){
return "Sides: " + a + b + c + d ;
}
1