From cd459897246fc8a6be034c554a3098fe0dceda6f Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Fri, 7 Aug 2026 22:06:19 +0300 Subject: [PATCH 1/2] added question --- source/ch5_loopsanditeration.ptx | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/source/ch5_loopsanditeration.ptx b/source/ch5_loopsanditeration.ptx index 28cbde4..743e916 100644 --- a/source/ch5_loopsanditeration.ptx +++ b/source/ch5_loopsanditeration.ptx @@ -183,6 +183,59 @@ public class StringIterationExample { + + +

+ Rearrange the blocks to create a Java method that accepts an upper bound integer limit and calculates the sum of all even numbers from 2 up to and including limit. +

+
+ + + public int sumEvens(int limit) { + + + + + int total = 0; + + + int total; + + + + + + for (int i = 2; i <= limit; i += 2) { + + + for (int i = 2; i < limit; i =+ 2) { + + + + + + total += i; + } + + + total = i; + } + + + + + + return total; + } + + + return i; + } + + + +
+
From c0402e8eb44c8ef47fec7fae1c9ecf06f3431d18 Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Fri, 7 Aug 2026 22:16:27 +0300 Subject: [PATCH 2/2] spacing --- source/ch5_loopsanditeration.ptx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ch5_loopsanditeration.ptx b/source/ch5_loopsanditeration.ptx index 743e916..7c6819b 100644 --- a/source/ch5_loopsanditeration.ptx +++ b/source/ch5_loopsanditeration.ptx @@ -234,7 +234,7 @@ public class StringIterationExample { - +