利用Java bean 求梯形面积,梯形上下底和高由表单输入。

在线等 谢谢了袄
2024-12-27 01:26:06
推荐回答(2个)
回答1:

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;
}
}

回答2:

java bean 很好写的啊

梯形表单,也很好写的啊,

return area=(a+b)*h/2 按照这个公式写吧,相信有点基础都能写得出来。加油