怎么用java计算梯形面积 Suppose that bases of a trapezoid are 8.9 and 12.1,and that the height is 16.Use Dr.Java's interactions pane to declare variables for the bases,height,and area,assign values,and compute the area.What code did you type
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 02:12:47
怎么用java计算梯形面积 Suppose that bases of a trapezoid are 8.9 and 12.1,and that the height is 16.Use Dr.Java's interactions pane to declare variables for the bases,height,and area,assign values,and compute the area.What code did you type
怎么用java计算梯形面积
Suppose that bases of a trapezoid are 8.9 and 12.1,and that the height is 16.Use Dr.Java's interactions pane to declare variables for the bases,height,and area,assign values,and compute the area.
What code did you type to declare the four variables you needed?
What code did you type to assign values to the bases and the height?
What code did you type to compute the area?
What is the area of this trapezoid?
怎么用java计算梯形面积 Suppose that bases of a trapezoid are 8.9 and 12.1,and that the height is 16.Use Dr.Java's interactions pane to declare variables for the bases,height,and area,assign values,and compute the area.What code did you type
public class Test{
//梯形面积的方法
//a为梯形上底,b为梯形下底,h为梯形高,area为面积
public double area(double a,double b,double h){
double area;
//梯形面积公式:(上底+下底)*高/2
area=(a+b)*h/2;
return area;
}
//使用mian()方法实现
public static void main(String [] args){
Test t=new Test();
System.out.print("梯形面积为"+t.area(8.9,12.1,16));
}
}