Skip to content

Commit 8cee71a

Browse files
committed
Add Calculator.java with arithmetic methods
1 parent 338066e commit 8cee71a

File tree

1 file changed

+23
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)