From 3e56229e00522689b703d51a1def23a7ed1aa796 Mon Sep 17 00:00:00 2001 From: Abdul Karim Date: Sun, 15 Feb 2026 13:19:36 +0500 Subject: [PATCH 1/2] 12.9. Challenges: Add challenge of multiple if statements --- src/branching_logic/challenges.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/branching_logic/challenges.md b/src/branching_logic/challenges.md index 452b2fa..b6be8d9 100644 --- a/src/branching_logic/challenges.md +++ b/src/branching_logic/challenges.md @@ -26,6 +26,21 @@ if the number is odd. ## Challenge 3 +What will this program output when run? Write down your guess and then try running it. + +```java,editable +void main() { + int num = 10; + + if (num > 1) + IO.println("It is greater than 1"); + if (num > 5) + IO.println("It is greater than 5"); +} +``` + +## Challenge 4 + Write code that will output `allowed` if the the `password` variable is equal to `"abc123"` and `not allowed` if it isn't. @@ -39,7 +54,7 @@ void main() { } ``` -## Challenge 4 +## Challenge 5 Write code that will assign the string `The number {x} is even` to `message` if `x` is an even number and `The number {x} is odd` if `x` is an odd number. From 709d3a7b50848d0585b2bbe0cabc7dcc8b4d373d Mon Sep 17 00:00:00 2001 From: Abdul Karim Date: Sun, 15 Feb 2026 13:50:01 +0500 Subject: [PATCH 2/2] Add hints and solution --- src/branching_logic/challenges.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/branching_logic/challenges.md b/src/branching_logic/challenges.md index b6be8d9..a06593f 100644 --- a/src/branching_logic/challenges.md +++ b/src/branching_logic/challenges.md @@ -38,6 +38,23 @@ void main() { IO.println("It is greater than 5"); } ``` +
+ Hint 1: +

Else if statements only execute if previous condition is false.

+
+ +
+ Hint 2: +

If statements always execute.

+
+ +
+ Solution +

+It is greater than 1
+It is greater than 5
+

+
## Challenge 4