Skip to content

Instantly share code, notes, and snippets.

@roma-sck
Created December 30, 2014 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roma-sck/d4551ca8592e3f1f7a5e to your computer and use it in GitHub Desktop.
Save roma-sck/d4551ca8592e3f1f7a5e to your computer and use it in GitHub Desktop.
com.javarush.test.level06.lesson08.task03
package com.javarush.test.level06.lesson08.task03;
/* Класс Util
Реализовать статический метод double getDistance(x1, y1, x2, y2). Он должен вычислять расстояние между точками.
Используй метод double Math.sqrt(double a), который вычисляет квадратный корень переданного параметра
*/
public class Util
{
public static double getDistance(int x1, int y1, int x2, int y2)
{
double result = 0;
// расстояние между точками,определяется из условия d2 = (х2— х1)2 + (y2— y1)2.
// Отсюда d = \/(х2— х1)2 + (y2— y1)2
result = Math.sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment