Skip to content

Commit cf7246c

Browse files
Update calculator
1 parent 8c39974 commit cf7246c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
package calculator;
22

33
public class Calculator {
4-
public static int add(int x, int y) {
4+
public static double add(double x, double y) {
55
return x + y;
66
}
7+
8+
public static double subtract(double x, double y) {
9+
return x - y;
10+
}
11+
12+
public static double multiply(double x, double y) {
13+
return x * y;
14+
}
15+
16+
public static double divide(double x, double y) {
17+
if (y == 0) {
18+
System.out.println("Cannot divide by 0");
19+
return 0;
20+
}
21+
return x / y;
22+
}
723
}

0 commit comments

Comments
 (0)