← All Exercises
Java Math Operations
basicjava
Background
The Java Math class provides mathematical functions with IEEE 754 floating-point semantics.
Problem
Write a Java method that computes the Euclidean distance between two 2D points using Math.sqrt and Math.pow.
Input
Two points as (x1, y1) and (x2, y2) doubles.
Output
The Euclidean distance as a double.
Sample tests
Sample 1
Input: (0,0) and (3,4)
Expected: 5.0
Your solution
Learning objective
Learn Math class methods, floating-point arithmetic, and the hypot alternative for numerical stability.