Can you explain what i need to do?

# I dont understand the exercise

Resolved

Comments (13)

- Popular
- New
- Old

You must be signed in to leave a comment

Marex333

3 August 2021, 10:28

You operate on X and Y axis.
You need to calculate line between x1, y1 and x2, y2. Try to take paper and draw that and make such a points.
What you can do is to calulate horizontal line between points x1, x2 and vertical y1, y2. You will get "L" shape. If you would like to create triangle, the missing line ("L" shape") would be the line that you need for this task. All you need to do right now is to use pattern to find lenght of side of triangle.
It's a^2 + b^2 = c^
c = c^2 / c^2
SOLUTION
xDistance = x1 - x2
yDistance = y1 - y2
(you dont need to worry about getting minus, because you gonna make it square later = always positive)
resultSquare = xDistance * xDistance + yDistance + yDistance
result = resultSquare / resultSquare (in task you need to use method)
result = Math.sqrt(resultSquare)

0

Brandon Leirer

11 June 2020, 21:56

why is this a level 6 assignment? None of this has been covered yet.

+1

Lukas Smetana

27 July 2019, 15:11

Got it, thanks

0

Anonymous #10410173 Full Stack Developer

26 July 2019, 14:09

just use co-ordinate geometry to solve this problem and use the distance formula.
there is nothing like programming concept. its only revision of basic mathematics.

+1

Johannes

4 March 2020, 11:28

"basic mathematics" ??
The requirements don't say what they actually want. Distance between 2 points ? That's a and b. But here there're 4 points given, makes no sense. Should state a little more clearly what they require, then I can actually understand it.

+5

Johannes

4 March 2020, 11:30

If they clearly said: One point is a point with the following coordinates (x,y) and the other point has coordinates (x2,y2), it would make more sense to someone that's not immediately clear that these are "coordinates", not 2 "points". What's to say there couldn't be a 3rd coordinate (depth) ?

+5

Onar D.

6 October 2021, 11:11

even now i dont get it. :| .

0

Lisa

6 October 2021, 12:31

Look at that Wikipedia article: Euclidean distance
Most probably you just need to study the upper right picture to get it

+1

Onar D.

7 October 2021, 16:12

thanks a lot. i get it.

0

Lukas Smetana

26 July 2019, 10:13

Got it ! Thanks.

0

reena

26 July 2019, 05:35

In the exercise it is asked to find the distance between two points. The coordinates of the two points are given as (x1, x2) and (y1,y2). To find the distance between the two you can use this formula
Distance =√(x2−x1)^2+(y2−y1)^2
(please see here to see the correct distance formula https://www.mathsisfun.com/algebra/distance-2-points.html)

+4

Tonatiuh

19 October 2019, 18:07

Just remember that Java does not have an exponent operator like some other languages. A common mistake is to assume 3^2 is 3 to the 2nd power. It is not. The caret ^ is a valid operator in Java (and similar languages), but it is binary XOR.

0

Dmitriy Bursa

25 July 2019, 17:22

use Math module

+5