public class Trapezoidal {
private float top;
private float bottom;
private float height;
private float area;
public float getTop() {
return top;
}
public void setTop(float top) {
this.top = top;
}
public float getBottom() {
return bottom;
}
public void setBottom(float bottom) {
this.bottom = bottom;
}
public float getHeight() {
return height;
}
public void setHeight(float height) {
this.height = height;
}
public float getArea(){
this.area=((getTop()+getBottom())*getHeight())/2;
return area;
}
}
java bean 很好写的啊
梯形表单,也很好写的啊,
return area=(a+b)*h/2 按照这个公式写吧,相信有点基础都能写得出来。加油