Have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Decision Making Structures
What 4 decision making statements does java programming language provide?
1. if statement
2. if.,else statement
3. nested if statement
4. switch statement
An if statements consists of a - expression followed by one or more statements
Boolean
If the Boolean expression evaluates to true then the block of code inside the - will be executed.
if statement
What is else if...else statement useful for?
To test various conditions using single if...else if statement.
An if can have - or one else's and it must come after any else if's.
zero
An if can have zero to many else if's and they must come - the else.
before
Once an else if succeeds, none of the remaining else if's or else's will be -
tested.
A statement that allows a variable to be tested for equality against a list of values.
SWITCH statement
Each value in a switch statement is called a -
Case
What are the 4 types of variables that a switch statement can be?
1. integers,
2. convertable integers (byte, short, char),
3. strings
4. and enums
You can have any number of case statements within a -. Each case is followed by the value to be compared to and a colon.
switch
The value for a case must be the same data type as the variable in the switch and it must be a x or a y.
constant or a literal
When the variable being switched on is equal to a case, the statements following that case will execute until a - is reached.
break statement
When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the -
switch statement
Not every case needs to contain a break. If no break appears, the flow of control will fall through to subsequent cases until a - is reached.
break
A switch statement can have an optional -, which must appear at the end of the switch. The - can be used for performing a task when none of the cases is true. No break is needed in the -.
default case