diff --git a/src/Calculator.java b/src/Calculator.java index 8a4b66a4c0ec7488171ede6c6f7a63aa5ddc6bba..45d7d3b471de6339a514bbbf98d26a9774556a20 100644 --- a/src/Calculator.java +++ b/src/Calculator.java @@ -23,5 +23,11 @@ public class Calculator { } return a / b; } + public double squareRoot(double a) throws IllegalArgumentException { + if (a < 0) { + throw new IllegalArgumentException("Cannot compute the square root of a negative number"); + } + return Math.sqrt(a); + } }