Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.
AND
|
Logical AND |
OR
|
Logical OR |
XOR
|
Logical Exclusive OR |
NOT
|
Logical Complement |
evaluate each of the following expressions:
true OR false
true AND false
true AND (false OR true)
false AND (false OR true)
NOT (false OR (true AND true))
(true OR false) AND (true AND false)
(true XOR false) XOR true
(false XOR false) XOR false
&&
|
Logical AND |
||
|
Logical OR |
!
|
Logical Complement |
evaluate each of the following expressions:
true || true
true && true
(!true) && true
(!(true || false)) && (true && false)
==
|
Equal to |
>
|
Greater than |
<
|
Less than |
>=
|
Greater than or equal to |
<=
|
Less than or equal to |
!=;
|
Not equal to |
and the following logical operators (with equal precedence but lower precedence than the relational operators):
&&
|
Logical AND |
||
|
Logical OR |
!
|
Logical Complement |
evaluate each of the following expressions:
(5 > 5)
(5 >= 2) && (10 < 100)
(4 == 2) && (10 >= 10)
!(2 <= 10)
(41 >= 40)
(!(5 >= 2)) || ((10 < 100) && (8 != 8))
&&
|
Logical AND |
||
|
Logical OR |
!
|
Logical Complement |
the following relational operators (with equal precedence):
==
|
Equal to |
>
|
Greater than |
<
|
Less than |
>=
|
Greater than or equal to |
<=
|
Less than or equal to |
!=
|
Not equal to |
the following arithmetic operators (in decreasing precedence):
*
|
Multiplication |
/
|
Integer Division |
%
|
Remainder |
+
|
Addition |
-
|
Subtraction |
and the following declarations and initializations:
final boolean X = true;
final double Y = 7.0;
final int Z = 7;
what type must be each of the following variables on the left side of the assignment operator?
b = (5 > Z);
i = (5 % 7);
b = (X || false);
b = (5 < 7) && (6 == 3);
d = (5 / Y);
&&
|
Logical AND |
||
|
Logical OR |
!
|
Logical Complement |
the following relational operators (with equal precedence):
==
|
Equal to |
>
|
Greater than |
<
|
Less than |
>=
|
Greater than or equal to |
<=
|
Less than or equal to |
!=
|
Not equal to |
and the following arithmetic operators (in decreasing precedence):
*
|
Multiplication |
/
|
Integer Division |
%
|
Remainder |
+
|
Addition |
-
|
Subtraction |
evaluate the following expressions or indicate the errors they contain:
(5 >= 5) && ((10 > 10) || (3 == 3))
(5 % 3) + (8 / 16)
3 < 5 < 7
5 == ((5 / 2) * 2)
5 > 3 && 2
b
using the println()
function as follows:
System.out.println(b);
.)
int
variable
today
denote the
integer corresponding to today and letting the int
variable due
denote the day of the week (during this week)
that an assignment is due,
write an expression that evaluates to true
when
the assignment is late. (Note: You should assume that we are only concerned
with a single week.)
boolean
variable
late
denote whether the assignment is late or not.
Write a statement that assigns the value true
to late
when the assignment is late.
int
variable
today
denote the
integer corresponding to today and letting the int
variable days
denote the number of days in the future
we are interested in, and the int
constant
DAYS_PER_WEEK
denote the numer of days in a week,
write an expression that evaluates to true
if
the day in the future is the same day of the week as today.
true
if the two right-most digits of the int
named
year
are 13
. (You may assume that
year
has four digits.)
true
if the double
named
salary
has exactly "seven figures" (i.e., 7 digits).
Copyright 2013