JAVA期末考试题库

}}

10. 若三角形的三边长分别为a,b,c,编写一个方法计算该三角形的面积。提示:三角形的面积= ,其中:s=(a+b+c)/2。 public class Rectangle {

private double a,b;//a是长,b是宽 private double perimeter, area;

public Rectangle(double pa, double pb) {a=pa;b=pb; } public static void main(String[] args) { // TODO code application logic here

Rectangle myRectangle=new Rectangle(2,3); System.out.println(\\ System.out.println(\\

public double getPerimeter(){return 2*a+2*b;}public double getArea(){return a*b;}}

33

联系客服:779662525#qq.com(#替换为@)