Java Arena
Step 4 of 6

else

else adds a second block that runs when the condition is false. Exactly one of the two blocks runs, never both, never neither:

int balance = -4;
if (balance >= 0) {
    System.out.println("Balance OK");
} else {
    System.out.println("Overdrawn");
}
Output
Overdrawn

else has no condition of its own: it simply catches every case the if didn't. The } else { line closes the first block and opens the second, so it lines up with the if.

Your task

Challenge 1 of 3

Read the hour of the day (0 to 23) and print Good morning when it's before 12, and Good afternoon otherwise. For the input 9 the program prints:

Good morning

Challenge 2

Read an age and print Adult for 18 or older, otherwise Not yet an adult. For the input 18 the program prints:

How old are you?
Adult

Challenge 3

Read a number of points. With 50 or more, print Passed with N points; otherwise N points is not enough, 50 needed. For the input 72 the program prints:

Passed with 72 points