For this coding challenge, we are going to create a class called
CodingChallenge4 and create a boolean variable called
I_like_sushi . You can assign it either a true or false value based on whether you are a Sushi fan.
Then, we are going to create an
if and an
else if statement. For the
if statement, you will have Java print a sentence (that you can make up) for when
I_like_sushi is true.
else if statement, you will have Java print a sentence (that you can also make up) for when
I_like_sushi is false.
If you get caught up, you can scroll down to see what I came up with. As always, have fun and think like a computer!
The output for the code above would be:
Raw fish? No thanks! This is because the
if statement is ignored because the boolean does not equal true. Therefore, the computer goes down to the
else if statement and executes that code because the conditional statement evaluates to true!
Great job and see you in the next Chapter!
Leave a Reply