Answer:
<em>import java.util.Scanner;</em>
<em>public class TestClass {</em>
<em> public static void main(String[] args) {</em>
<em> Scanner input = new Scanner(System.in);</em>
<em> System.out.println("Enter value for x1, x2, y1, y2");</em>
<em> double x1 = input.nextDouble();</em>
<em> double x2 = input.nextDouble();</em>
<em> double y1 = input.nextDouble();</em>
<em> double y2 = input.nextDouble();</em>
<em> double xVal = Math.pow((x2-x1),2);</em>
<em> double yVal = Math.pow((y2-y1),2);</em>
<em> double distance = Math.sqrt(xVal+yVal);</em>
<em> System.out.println(distance);</em>
<em> }</em>
<em>}</em>
Explanation:
The code is written in Java Programming Language.
This code simply implements the formula for the distance between two points given as
distance =
The scanner class is used to prompt and receive all the variables that are declared.
Note that we used two special Java methods (Math.pow and Math.sqrt)