Distance between two points

  • 5
  • Locked
You're aware that you can draw a straight line between any two points in a plane, right? Probably, but if not, check out Euclid and his treatise called "Elements". Better yet, take this assertion on faith and write a static double getDistance(x1, y1, x2, y2) method. It should calculate the distance between two points.
You can't complete this task, because you're not signed in.
Comments (12)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Aron
Level 14
8 July 2021, 20:53
under 5 min video, explaining how to calculate distance
Angelo Tratsis
Level 8 , Boston, United States
26 April 2021, 18:15
Usman Full Stack Developer at QA
1 July 2021, 16:19
you legend, saved me the hassle of googling :D
Karas Java Developer
1 September 2020, 22:47
Okay... wait... wait.... we are here to learn java, not quadratic mathematics. https://www.mathwarehouse.com/algebra/distance_formula/index.php Pythagorean Theorem in simple terms
Nastya
Level 19 , Moscow, Russia
7 May 2020, 17:03
Martzehh
Level 9 , Ottawa, Canada
2 June 2020, 18:46
Thank you!!
Khongpak Phupkdee
Level 15 , Chiangrai, Thailand
15 March 2021, 15:05
Thank you
Nickolas Johnson
Level 8 , St. Louis, United States of America
13 March 2020, 15:29
Mathisfun.com completely screwed me on this one. I thought i was using the right formula but i guess not.
Tonatiuh
Level 12 , Mexico, Mexico
19 October 2019, 18:01
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.
shivani maski
Level 8 , Shizuoka, Japan
26 August 2019, 08:56
Why this is showing error here ---->double Math.sqrt(double a); ^ I am getting below error: com/codegym/task/task06/task0609/Util.java:14: error: ';' expected double Math.sqrt(double a);
Hannah Software Architect
14 January 2020, 09:00
did you changed the variables name?
coffeemess
Level 8 , Versailles, France
1 August 2021, 18:07
I faced the same error you should use just Math.sqrt(double a) (without double in the beginning)