Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decisions with if statements. Simple If Statements if (age < 18) g.drawString(You may not vote., 50, 50); Evaluating a single expression.

Similar presentations


Presentation on theme: "Decisions with if statements. Simple If Statements if (age < 18) g.drawString(You may not vote., 50, 50); Evaluating a single expression."— Presentation transcript:

1 Decisions with if statements

2 Simple If Statements if (age < 18) g.drawString(You may not vote., 50, 50); Evaluating a single expression

3 Simple If Statements if (age > 18) g.drawString(You may vote., 50, 50); Evaluating a single expression

4 Simple If Statements if (age >= 18) g.drawString(You may vote., 50, 50); Evaluating a single expression

5 Simple If Statements if (age != 16) g.drawString(You are not sixteen years old., 50, 50); Evaluating a single expression

6 Simple If Statements if (age == 16) g.drawString(You are sixteen years old., 50, 50); Evaluating a single expression

7 Logical Opereators >Greater than <Less than ==Equal to !=Not equal to <=Less than or equal to >=Greater than or equal to

8 Equal Signs =This is used to assign values to variables. int sliderValue = 0; ==This is used to compare values. if (age == 16)

9 Multiple Comparisons if (age >= 21 && age < 65) g.drawString(You may be an airline pilot., 50, 50); Evaluating multiple expressions

10 Multiple Comparisons if (age = 65) g.drawString(You may not be an airline pilot., 50, 50); Evaluating multiple expressions

11 If-Else Statements if (age < 18) g.drawString(You may not vote., 50, 50); else g.drawString(You may vote., 50, 50); Using Else with If statements

12 If-Else Statements if (age = 65) g.drawString(You may not be an airline pilot., 50, 50); else g.drawString(You may be an airline pilot., 50, 50); Using Else with If statements

13 Grouping Statements if (age < 18) { g.drawString(You may not vote., 50, 50); g.drawString(You may not serve in the military., 50, 50); g.drawString(You may not sign business contracts., 50, 50); } else { g.drawString(You may vote., 50, 50); g.drawString(You may serve in the military., 50, 50); g.drawString(You may sign business contracts., 50, 50); } Grouping statements with braces


Download ppt "Decisions with if statements. Simple If Statements if (age < 18) g.drawString(You may not vote., 50, 50); Evaluating a single expression."

Similar presentations


Ads by Google