已運(yùn)行(未作修改).運(yùn)行結(jié)果:
(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.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}
}
不能運(yùn)行 總是找不到符號(hào)
怎么回事啊
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}
}
不能運(yùn)行 總是找不到符號(hào)
怎么回事啊
其他人氣:870 ℃時(shí)間:2020-05-21 21:15:20
優(yōu)質(zhì)解答
我來回答
類似推薦
- Java里n =(int)Math.sqrt((double)i)是什么意思?
- Math.abs(x)及同類的的公式
- 草字頭+佳 是什么字
- empty what is full,fill what is empty! 永遠(yuǎn)不讓自己空虛,永遠(yuǎn)不讓自己自滿 給點(diǎn)點(diǎn)評(píng)
- 16S rRNA基因通用引物1492r/F27,1492和27分別是什么意思?編號(hào)么?
- 用短除法分解素因素:42 81 40
- 在長(zhǎng)1.6米,寬1.2米的長(zhǎng)方形三合板上,裁出半徑是20厘米的圓,最多可裁多少個(gè)?
- 線性代數(shù) 設(shè)A,B,C均為n階矩陣,I為n階單位矩陣,且ABC=I,則下列矩陣乘積一定等于I的是哪個(gè)?
- 試以下面的方程為例,敘述用分離變量法求解方程的步驟.
- 《父親學(xué)畫》閱讀答案
- engage與undertake的區(qū)別,各自的用法
- how are you doing 同義句 how ________everything______________?
猜你喜歡
- 1每天堅(jiān)持朗讀對(duì)學(xué)外語有什么好處?
- 2You are yuji?急.
- 3思密達(dá)到底是什么意思
- 4計(jì)算(a的立方-b的立方)+ab(a-3b)-2(b的立方-a的平方b)
- 5求寫英語書面表達(dá)
- 6油酸的作用是什么
- 7請(qǐng)幫忙翻譯:Payment and and Charging
- 8近紅外區(qū)的吸收光譜代表什么含義?
- 9大正方形邊長(zhǎng)為15cm,小正方形邊長(zhǎng)為10cm.求陰影甲的面積比陰影乙的面積大多少平
- 10有甲乙丙三種文具,若購甲2件,乙1件、丙3件共需23元,若夠甲1件、乙4件、丙5件共需36元,問夠甲一件,乙2件,丙3件共需多少元
- 11Jack has a dog and so have I.____dog and____had a fight
- 12英語翻譯