Skip to content

Commit 3e56229

Browse files
12.9. Challenges: Add challenge of multiple if statements
1 parent 7f43e1a commit 3e56229

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/branching_logic/challenges.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ if the number is odd.
2626

2727
## Challenge 3
2828

29+
What will this program output when run? Write down your guess and then try running it.
30+
31+
```java,editable
32+
void main() {
33+
int num = 10;
34+
35+
if (num > 1)
36+
IO.println("It is greater than 1");
37+
if (num > 5)
38+
IO.println("It is greater than 5");
39+
}
40+
```
41+
42+
## Challenge 4
43+
2944
Write code that will output `allowed` if the the `password` variable is equal to
3045
`"abc123"` and `not allowed` if it isn't.
3146

@@ -39,7 +54,7 @@ void main() {
3954
}
4055
```
4156

42-
## Challenge 4
57+
## Challenge 5
4358

4459
Write code that will assign the string `The number {x} is even` to `message` if `x` is an even number
4560
and `The number {x} is odd` if `x` is an odd number.

0 commit comments

Comments
 (0)