编写Java应用程序,该程序中有梯形类和主类。要求如下: (1)梯形类具有属性上底、下底、高和面积,具有返回面积 的功能,在构造方法中对上底、下底和高进行初始化。 (2)主类
public class Trape {
float upBottom,downBottom,height;
Trape(){
upBottom=3.2f;
downBottom=3.2f;
height=3.4f;
}
float s(){
return (upBottom+downBottom)*height/2;
}
}
package gh;
public class text2 {
public static void main(String[] args) {
Trape myTrape=new Trape();
System.out.println(myTrape.s());
}
}
