Skip to content

Commit 48b8cc8

Browse files
add cal.java file
1 parent f03de6c commit 48b8cc8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Calculator.java

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

0 commit comments

Comments
 (0)