Download presentation
Presentation is loading. Please wait.
Published byNeal Shon Manning Modified over 9 years ago
1
Conditional statements and boolean expressions Arithmetic, relational and logical operators
6
boolean expression A boolean expression has only two possible values: true and false. They are commonly found controlling the choice between two paths through a conditional statement. It establishes the criterion for either skipping a group of statements or executing those statements.
19
Will this work? if (noiseDb <= 110) { System.out.println(“Noise is very annoying”); } else if (noiseDb <= 90) { System.out.println(“Noise is annoying”); } else if (noiseDb <= 70) { System.out.println(“Noise is intrusive”); } else if (noiseDb <= 50) { System.out.println(“Noise is quiet”); } else { System.out.println(“Noise is uncomfortable”); }
20
Does the code on the right do the same thing as the code on the left? if (x >= 1) { x = x + 2; } else if (x >= 0) { x = x + 1; } if (x >= 1) { x = x + 2; } if (x >= 0) { x = x + 1; }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.