COP 3502 Chapter Notes - Chapter 3: Logical Disjunction, Negation, Logical Conjunction

50 views4 pages

Document Summary

Programs can decide which statements to execute based on a condition. Selection statements-statements that let you choose actions with alternative courses. Boolean expression-an expression that evaluates a boolean value (i. e. true, false) The boolean data type declares a variable with the value either true or false. Java provides 6 relational operators (comparison operators) which can be used to compare 2 values. Example (x=5) x<0 x<=0 x>0 x>=0 x==0 x!=0. Boolean variable-variable that holds a boolean value (e. g. boolean variable=true;) A construct that enables a program to specify alternative paths of execution if(boolean expression) statement(s); If boolean expression evaluates to true, the statement(s) in the block are executed. An if-else statement decides the execution path based on whether the condition is true or false. if(boolean expression) else statement(s) for true; statement(s) for false; An if statement can be inside another if statement to form a nested if statement. if(boolean expression) if(boolean expression) statement(s);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents