java Math.abs和Math.sqrt
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/16 14:01:37
java Math.abs和Math.sqrt
class Line
{
double p1x;
double p2x;
double p1y;
double p2y;
public Line(double p1x,double p1y,double p2x,double p2y){
this.p1x=p1x;
this.p2x=p2x;
this.p1y=p1y;
this.p2y=p2y;
}
public String toString(){
return "(" + p1x + "," + p1y + ")-(" + p2x + "," + p2y + ")";
}
public double getLength(){
double a=Math.abs(p1x-p2x);
double b=Math.abs(p1y-p2y);
double c=Math.sqrt(a*a+b*b);
\x09 return c;
}
\x09public static void main(String[] args)
\x09{
\x09Line line1 = new Line(10.5,20.1,100.0,50.0);
\x09Line line2 = new Line(-1.0,0.0,0.0,1.0);
\x09System.out.println(line1);
\x09System.out.println(line1.getLength());
\x09System.out.println(line2);
\x09System.out.println(line2.getLength());
\x09}
}
不能运行 总是找不到符号
怎么回事啊
class Line
{
double p1x;
double p2x;
double p1y;
double p2y;
public Line(double p1x,double p1y,double p2x,double p2y){
this.p1x=p1x;
this.p2x=p2x;
this.p1y=p1y;
this.p2y=p2y;
}
public String toString(){
return "(" + p1x + "," + p1y + ")-(" + p2x + "," + p2y + ")";
}
public double getLength(){
double a=Math.abs(p1x-p2x);
double b=Math.abs(p1y-p2y);
double c=Math.sqrt(a*a+b*b);
\x09 return c;
}
\x09public static void main(String[] args)
\x09{
\x09Line line1 = new Line(10.5,20.1,100.0,50.0);
\x09Line line2 = new Line(-1.0,0.0,0.0,1.0);
\x09System.out.println(line1);
\x09System.out.println(line1.getLength());
\x09System.out.println(line2);
\x09System.out.println(line2.getLength());
\x09}
}
不能运行 总是找不到符号
怎么回事啊
已运行(未作修改).运行结果:
(10.5,20.1)-(100.0,50.0)
94.36238657431254
(-1.0,0.0)-(0.0,1.0)
1.4142135623730951
(10.5,20.1)-(100.0,50.0)
94.36238657431254
(-1.0,0.0)-(0.0,1.0)
1.4142135623730951
java Math.abs和Math.sqrt
java,Math.PI和Math.
JAVA中,% == && || Math.sqrt(x) Math.pow Math.floor(x) Math.ro
math.cos(75*3.14/180)+math.sqrt(x+math.exp(3))/math.Abs(x-y)
Java里n =(int)Math.sqrt((double)i)是什么意思?
k=java.lang.Math.sqrt(m) 是不是调用java里面本来就有的函数?
JAVA用Math.sqrt计算2的算术平方根,怎样调精度?
MATH,
math math math math
math
java中的math.ceil是什么意思
java的math类怎么用三角函数