当前位置: > java Math.abs和Math.sqrt...
题目
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}
}
不能运行 总是找不到符号
怎么回事啊

提问时间:2021-03-31

答案
已运行(未作修改).运行结果:
(10.5,20.1)-(100.0,50.0)
94.36238657431254
(-1.0,0.0)-(0.0,1.0)
1.4142135623730951
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.