Using Nested If Statements
In some cases, you want to include an if statement within an if statement. This is referred to as a nested if statement.
Your Turn
Let's try it in the Java Playground.
- In the example below, players who have accumulated
10 or more points will get a bonus that is two times the value of points. The if statement that adjusts bonus is nested in the if statement that adjusts the value of points if score is greater than or equal to 25.
- Predict the output of the code.
- Run the code to determine if your prediction is correct.
- Adjust the initial value of
points to be 10.
- Predict the output of the code.
- Run the code to determine if your prediction is correct.
Resources
Next Learn Tutorial