CS 111 - 10/22/15
Lab 7 Available to turn in thru 11:59pm on 10/22/15
Project 2 On time if turned in by 11:59pm Friday 10/23/15
Complex Condition
Where 2 or more boolean expressions are used to determine
the overall condition
Example: is a value in the range from 10 to 20 (inclusive)?
There is a set of operators called the Boolean Operators
AND: && binary operator (it takes two operands)
OR: || binary operator (it takes two operands)
NOT: ! unary operator (it takes one operand)
The result of an AND operation will be TRUE if both boolean expressions
evaluate to TRUE;
otherwise the result is FALSE
The result of an OR operation will be TRUE if either or both
boolean expressions evaluate to TRUE;
otherwise the result is FALSE
The result of a NOT operation will be TRUE
if the operand is initally FALSE.
The result of a NOT operation will be FALSE
if the operand is initally TRUE
Truth Table for Boolean Operators
X Y | X && Y X || Y !X
=======================================
t t | t t f
t f | f t f
f t | f t t
f f | f f t
X | !x
================
t | f
f | t
Example: is a value in the range from 10 to 20 inclusive
if ( ( x >= 10 ) && ( x <= 20 ) )
{
System.out.println ("The value is in the range from 10 to 20");
}
Example: is a value outside of the range from 10 to 20 inclusive
if ( ( x < 10 ) || ( x > 20 ) )
{
System.out.println ("The value is outside of the range from 10 to 20");
}
Example: if the value NOT equals to 7
if ( ! ( x == 7 ) )
{
System.out.println ("The value is not equal to 7");
}
However most people will write the code as:
if ( x != 7 )
{
System.out.println ("The value is not equal to 7");
}
===========================
So far our picture manipulation has revolved around color changing.
Now we want to to position manipiulation
First UP: Mirror image
items on the left side go to the right side.
items on the left side go to the right side.
We normally need to create a blank canvas to store the resulting
image for the manipulation.