creation: 07/07/06
1. Complete the following truth table:
Decide from the table what the value of the expression is
is when x == 150
and y == 125
.
2. Complete the following truth table:
Decide from the table what the value of the expression is
is when ch == 'A'
.
3. Complete the following truth table:
Decide from the table what the value of the expression is
is when ch == 'x'
.
4.
Is !A && B
equivalent to A || !B
?
Complete the table to find out.
The two expressions are equivalent if the T/F values in the last two columns are the same.
Now use De Morgan's Rule:
!(A && B) is equivalent to !A || !B
to rewrite !A && B
.
5. You wish to purchase a certificate of deposit, but only if the interest rate is greater than three percent and the minimum deposit is less than 10000. Fill in the blanks.
Rewrite the above fragment so that it fits the following.
(The first program fragment is probably the best way to write this.)
6.
A program is searching for books with a call number that starts "QA" published
between 1990 and 1995 (inclusive) with the word "web" in the title.
Assume that the attributes of a book are accessed by
book.getTitle()
, book.getDate()
, and book.getCall()
.
Recall that indexOf( String sub )
returns the integer index of the substring,
or -1 if the substring is not found.
(The first program fragment is probably the best way to write this.)
End of the Exercise. If you want to do it again, click on "Refresh" in your browser window. Click here to go back to the main menu.