Skip to content

Commit d25a7d2

Browse files
author
Adi-Sin101
committed
Add Calculator class with basic arithmetic methods
1 parent ea7fa5a commit d25a7d2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Features/Calculator.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Calculator {
2+
3+
public double add(double a, double b) {
4+
return a + b;
5+
}
6+
7+
public double subtract(double a, double b) {
8+
return a - b;
9+
}
10+
11+
public double multiply(double a, double b) {
12+
return a * b;
13+
}
14+
15+
public double divide(double a, double b) {
16+
if (b == 0.0) {
17+
throw new IllegalArgumentException("Division by zero");
18+
}
19+
return a / b;
20+
}
21+
}

0 commit comments

Comments
 (0)