Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conditional statements and boolean expressions Arithmetic, relational and logical operators.

Similar presentations


Presentation on theme: "Conditional statements and boolean expressions Arithmetic, relational and logical operators."— Presentation transcript:

1 Conditional statements and boolean expressions Arithmetic, relational and logical operators

2

3

4

5

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.

7

8

9

10

11

12

13

14

15

16

17

18

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; }


Download ppt "Conditional statements and boolean expressions Arithmetic, relational and logical operators."

Similar presentations


Ads by Google