From 315d7a530f883660ac2b4603c37998c5ced24f58 Mon Sep 17 00:00:00 2001 From: akbandaru <105567376+akbandaru@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:58:35 -0400 Subject: [PATCH 1/2] Added Expection Handling for Division --- src/com/jwetherell/algorithms/mathematics/Division.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/jwetherell/algorithms/mathematics/Division.java b/src/com/jwetherell/algorithms/mathematics/Division.java index c133f741..64fe9332 100644 --- a/src/com/jwetherell/algorithms/mathematics/Division.java +++ b/src/com/jwetherell/algorithms/mathematics/Division.java @@ -3,7 +3,12 @@ public class Division { public static final long division(int a, int b) { - long result = ((long) a) / ((long) b); + + try { + long result = ((long) a) / ((long) b); + } catch (IllegalArgumentException e) { + System.out.println("Dividing by zero"); + } return result; } From e39a64eabf51c07e90d3e710875b4475325b7b42 Mon Sep 17 00:00:00 2001 From: akbandaru <116668513+abandaru04@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:04:11 -0400 Subject: [PATCH 2/2] Hello First Comment --- src/com/jwetherell/algorithms/mathematics/Division.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/jwetherell/algorithms/mathematics/Division.java b/src/com/jwetherell/algorithms/mathematics/Division.java index 64fe9332..f9bb96e8 100644 --- a/src/com/jwetherell/algorithms/mathematics/Division.java +++ b/src/com/jwetherell/algorithms/mathematics/Division.java @@ -3,7 +3,7 @@ public class Division { public static final long division(int a, int b) { - + // Expection Handler try { long result = ((long) a) / ((long) b); } catch (IllegalArgumentException e) {