Professional Documents
Culture Documents
Outline
• If/else statement
• Switch case
• While loop
• Do while loop
• For loop
3
Decision statements
• The program can decide which statements to execute based on a condition.
• one-way if statements
• nested if statements
• conditional expressions.
4
Decision statm…
one way if statement
•A one-way if statement executes an action if and only if the condition is
true.
Syntax
Decision statm…
• The block braces can be omitted if they enclose a single statement. For
•
6
Dec statem…
Example.
Dec statmn…
• Example multi way if statement
Switch Statements
• A switch statement executes statements based on the value of a variable or
an expression.
8
Dec statem…
Loops in java
while Loop
•A while loop executes statements repeatedly while the condition is
true.