Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

EXCERCI

SE2

cl
assPoi
nt

doubl
ex;

doubl
ey;

Poi
nt(
)

x=0;

y
=0;

Poi
nt(
doubl
er,
doubl
es)

x=r
;

y
=s;

Poi
nt(
Poi
ntk)

x=k.
x;

y
=k.
y;

doubl
efi
nd_
dist
ance(
doubl
er,
doubl
es)

doubl
edi
st=Mat
h.sqr
t((
x-r
)*(
x-r
)+(
y-s)
*(y
-s)
);

r
etur
ndi
st;
}

doubl
efi
nd_
dist
ance(
Poi
ntk)

doubl
edi
stance=Mat
h.sqr
t((
x-k.
x)*
(x-
k.x)
+(y
-k.
y)*
(y-
k.y
));

r
etur
ndi
stance;

v
oiddi
spl
ay(
)

Sy
stem.
out
.pr
int
ln(
"(
"+x+"
,"
+y+"
)"
);

publ
i
cst
ati
cvoi
dmai
n(St
ri
ngar
gs[
])

Poi
ntp1=newPoi
nt(
3.25,
7.89)
;

Poi
ntp2=newPoi
nt(
5.37,
18.
12)
;

Poi
ntp3=newPoi
nt(
p2)
;

Sy
stem.
out
.pr
int
ln(
"t
hedi
stancebet
weent
hepoi
nts:
")
;

p1.
displ
ay(
);

Sy
stem.
out
.pr
int
ln(
"and(
7.9,
16.
25)i
s"+p1.
fi
nd_
dist
ance(
7.9,
16.
25)
);

Sy
stem.
out
.pr
int
ln(
"t
hedi
stancebet
weent
hepoi
nts:
")
;

p1.
displ
ay(
);

Sy
stem.
out
.pr
int
ln(
"and"
);

p3.
displ
ay(
);

Sy
stem.
out
.pr
int
ln(
"i
s"+p1.
fi
nd_
dist
ance(
p3)
);

}
OUTPUT:

You might also like