TestScore < 80 testScore * 2 >= 350 30 < w / (h * h) x + y != 2 * (a + b) 2 * Math.PI * radius <= 359.99 Relational Operators <//less than <=//less than.

Slides:



Advertisements
Similar presentations
3. S/E with Control Structures 3.1 Relational Operators and Expressions 3.2 If and if-else Statements 3.3 The Type Double 3.4 Program Design with the While.
Advertisements

1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
CS-1010 Dr. Mark L. Hornick 1 Selection Statements and conditional expressions.
Selection Statements & Exam 1 Review Recitation – 2/13/2009 CS 180 Department of Computer Science, Purdue University.
Chapter 5 Selection Statements. Topics Controlling program flow selection –if –switch Boolean expressions –boolean primitive type –comparison operators.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Selection Statements Primitive Type boolean.
1 9/15/06CS150 Introduction to Computer Science 1 Combined Assignments, Relational Operators, and the If Statement.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Selection Statements Animated Version.
Insight Through Computing 3. Introduction to Conditionals Boolean expressions The If-Else Construct And, or, not.
بسم الله الرحمن الرحيم CPCS203: Programming II. Objectives After you have read and studied this chapter, you should be able to Implement a selection control.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Selection Statements.
Flow of Control is Sequential unless a “control structure” is used to change that there are 2 general types of control structures: Selection (also called.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Selection Statements Primitive Type boolean.
Conditions, logical expressions, and selection Introduction to control structures.
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Control Statements.
Chapter Chapter 5 Selection Statements. Objectives Understand selection control statement –if statements –switch statements Write boolean expressions.
Boolean Expressions and If Flow of Control / Conditional Statements The if Statement Logical Operators The else Clause Block statements Nested if statements.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 5 Selection Statements Primitive Type boolean.
CSci 125 Lecture 10 Martin van Bommel. Simple Statements Expression followed by semicolon Assignments total = n1 + n2; Function calls printf(”Hello.\n”);
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
Decision Structures and Boolean Logic
Dale Roberts Program Control using Java - Boolean Expressions Dale Roberts, Lecturer Computer Science, IUPUI Department of.
Programming in Java (COP 2250) Lecture 11 Chengyong Yang Fall, 2005.
© 2006 Pearson Education 1 Obj: to use compound Boolean statements HW: p.184 True/False #1 – 6 (skip 3)  Do Now: 1.Test your “Charge Account Statement”
Conditionals & boolean operators
Chapter 4 Inequalities 4.1 Inequalities and Their Graphs.
Practice 1.2 Answers
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
Computer Science 111 Fundamentals of Programming I Making Choices with if Statements.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
1 © 2002 John Urrutia. All rights reserved. Qbasic Chapter 4 IF Statements and READ & DATA.
1 Programming in C++ Dale/Weems/Headington Chapter 5 Conditions, Logical Expressions.
CSC 1051 M.A. Papalaskari, Villanova University Conditional Statements Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University.
Chapter 51 Decisions Relational and Logical Operators If Blocks Select Case Blocks.
Relational and Boolean Operators CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Chapter 5: Objectives After you have read and studied this chapter, you should be able to Implement a selection control using if statements Implement a.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Control statements Mostafa Abdallah
Copyright 2008 by Pearson Education Building Java Programs Chapter 4 Lecture 4-1: if and if/else Statements reading: 4.2 self-check: #4-5, 7, 10, 11 exercises:
A: A: double “4” A: “34” 4.
booleans hold a true/false value We take advantage of this by using them to decide which route our program will take. Examples: stinky holds the boolean.
Operators.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
ICS102 Lecture 8 : Boolean Expressions King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
 Type Called bool  Bool has only two possible values: True and False.
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
APS105 Deciding 1. Comparing 2 Relational Expressions Relational expression: –Compare two values (or values of variables) Examples: x > 5 income < expenses.
Sequence, Selection, Iteration The IF Statement
Section 7.1 Logical Operators
Factors, multiple, primes: Factors from prime factors
Review Operation Bingo
Primitive and Reference Data Values
Computers & Programming Languages
Artificial Intelligence CS370D
Relational Operators Operator Meaning < Less than > Greater than
3-1 Inequalities and Their Graphs
3-1 Inequalities and their Graphs
Expressions.
Relational Operators.
Compound Conditionals
Factors, multiple, primes: Multiples
Standard Form: Multiplying powers of 10
Boolean Expressions September 1, 2019 ICS102: The course.
Standard form: In standard form?
Coordinates: Naming 2D coordinates – quadrant 1
Presentation transcript:

testScore < 80 testScore * 2 >= < w / (h * h) x + y != 2 * (a + b) 2 * Math.PI * radius <= Relational Operators <//less than <=//less than or equal to ==//equal to !=//not equal to >//greater than >=//greater than or equal to Gluuub … out to reality MakeBooleans.java

Boolean Expressions and Variables ABA && BA || B!A false true falsetruefalsetrue false truefalse true false Bbbblarp … out to reality CombineBooleans.java

Short-Circuit Evaluation Consider x > y || x > z The expression is evaluated left to right. If x > y is true, then there’s no need to evaluate x > z because the whole expression will be true whether x > z is true or not. To stop the evaluation once the result of the whole expression is known is called short-circuit evaluation. What would happen if the short-circuit evaluation is not done for the following expression? z == 0 || x / z > 20

Example Program Doodlingting … out to reality ShortCircuit.java

Operator Precedence Rules

Conditional Expressions Boolean values are used to form conditional expressions, whose value is determined by a Boolean expression. Lattteeee … out to reality Conditional.java