From 6ab6cc17db9fdbff7305e8c419e3324e711f509c Mon Sep 17 00:00:00 2001 From: Oleksii Aleshchenko Date: Thu, 16 Mar 2023 15:00:12 +0200 Subject: [PATCH] add break with label (commented in line 34) and return for lab1 --- src/Lab1.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Lab1.java b/src/Lab1.java index 3ddd967..e74c2ce 100644 --- a/src/Lab1.java +++ b/src/Lab1.java @@ -13,14 +13,14 @@ public class Lab1 { }*/ final int A = -3; - final int B = 1; + final int B = 0; final int N = 2; final int M = 2; final int C = 1; boolean wasDivisionByZero = false; // todo char - for (int i = A; i <= N && !wasDivisionByZero; i++) { +myLabel:for (int i = A; i <= N && !wasDivisionByZero; i++) { if (i + C == 0) { // todo optimize System.out.println("Division by zero!"); wasDivisionByZero = true; @@ -29,8 +29,9 @@ public class Lab1 { for (int j = B; j <= M; j++) { if (j == 0) { System.out.println("Division by zero!"); - wasDivisionByZero = true; - break; + return; +// wasDivisionByZero = true; +// break myLabel; } s += (double) (i / j) / (i + C); }