-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask5.java
52 lines (49 loc) · 1.21 KB
/
task5.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* The Calculator class provides methods to perform basic arithmetic operations.
*/
public class Calculator {
/**
* Adds two numbers.
*
* @param a The first number.
* @param b The second number.
* @return The sum of the two numbers.
*/
public static int add(int a, int b) {
return a + b;
}
/**
* Subtracts two numbers.
*
* @param a The first number.
* @param b The second number.
* @return The difference between the two numbers.
*/
public static int subtract(int a, int b) {
return a - b;
}
/**
* Multiplies two numbers.
*
* @param a The first number.
* @param b The second number.
* @return The product of the two numbers.
*/
public static int multiply(int a, int b) {
return a * b;
}
/**
* Divides two numbers.
*
* @param a The dividend.
* @param b The divisor.
* @return The quotient of the division.
* @throws IllegalArgumentException if the divisor is zero.
*/
public static int divide(int a, int b) {
if (b == 0) {
throw new IllegalArgumentException("Cannot divide by zero");
}
return a / b;
}
}