We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 438b0d4 commit 14acf1dCopy full SHA for 14acf1d
src/main/Calculator.java
@@ -0,0 +1,26 @@
1
+public class Calculator {
2
+
3
+ // Method to add two numbers
4
+ public int add(int a, int b) {
5
+ return a + b;
6
+ }
7
8
+ // Method to subtract two numbers
9
+ public int subtract(int a, int b) {
10
+ return a - b;
11
12
13
+ // Method to multiply two numbers
14
+ public int multiply(int a, int b) {
15
+ return a * b;
16
17
18
+ // Method to divide two numbers
19
+ public double divide(int a, int b) {
20
+ if (b != 0) {
21
+ return (double) a / b;
22
+ } else {
23
+ throw new ArithmeticException("Division by zero is not allowed.");
24
25
26
+}
0 commit comments