Find distance between two points on 2D surface

// 3. Find distance between two points on 2D surface
// Length of a line

class LineDistance {
public static void main(String[] args) {
// Point 1 (Starting point)
int x1 = 10;
int y1 = 20;
// Point 2 (Ending Point)
int x2 = 100;
int y2 = 120;

float distance = (float)Math.sqrt(Math.pow((y2 - y1), 2) + Math.pow((x2 - x1), 2));

System.out.println("Length of a line is " + distance);
}
}

Comments

Popular posts from this blog

Zeller's Congruence

Property Event-Delegation

Method with variable arguments