Skip to content

Commit a5d4253

Browse files
committed
squareroot added
1 parent 3cfe6f4 commit a5d4253

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Calculator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ public double divide(int a, int b) {
66
if (b == 0) throw new ArithmeticException("Divide by zero");
77
return (double) a / b;
88
}
9+
public double squareRoot(double number) {
10+
if (number < 0) throw new IllegalArgumentException("Cannot calculate square root of negative number");
11+
return Math.sqrt(number);
12+
}
913
}

0 commit comments

Comments
 (0)