当前位置 主页 > 澳门银河备用网址 >

java比值先定义壹个计算二维背靠标注系中圆面积

  

  public class CircleClass {

  double x0,x1,y0,y1;

  //test

  public static void main(String[] args) {

  CircleClass circle = new CircleClass(0,0,8.5,9);

  circle.cal();

  CircleClass circle2 = new CircleClass(2,3.5,9,6);

  circle2.cal();

  }

  //constructor

  public CircleClass(double x0,double y0,double x1,double y1){

  this.x0=x0;

  this.x1=x1;

  this.y0=y0;

  this.y1=y1;

  }

  //cal the area

  public void cal(){

  System.out.println("The area of the circle is----"+((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))*Math.PI);

  }

  }

  import java.lang.Math;

  public class Circle{

  float x=0,y=0;

  public Circle(float x,float y){

  this.x=x;

  this.y=y;

  }

  public float area(float x1,float y1){

  float area=0;

  area=Math.PI*(Math.pow((x1-x),2)+Math.pow(y1-y),2);

  return area;

  }

  }

  我没拥有拥有在编译器外面面写 己己己直接上顺手直接写的 父亲条约坚硬是此雕刻么的壹个文思 己己己验证壹下吧 学以次要己己己多动顺手啊