forked from examplehub/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivide.java
More file actions
34 lines (31 loc) · 790 Bytes
/
Divide.java
File metadata and controls
34 lines (31 loc) · 790 Bytes
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
package com.examplehub.maths;
public class Divide {
/**
* Divide two integer numbers.
*
* @param a the first number.
* @param b the second number.
* @return divide value of two integer numbers.
* @throws ArithmeticException if divisor is zero.
*/
public static int divide(int a, int b) {
if (b == 0) {
throw new ArithmeticException("divide by zero");
}
return a / b;
}
/**
* Divide two double numbers.
*
* @param a the first number.
* @param b the second number.
* @return divide value of two double numbers.
* @throws ArithmeticException if divisor is zero.
*/
public static double divide(double a, double b) {
if (b == 0.0) {
throw new ArithmeticException("divide by zero");
}
return a / b;
}
}