Homework #07 (Due: Mon 02 Feb)

It is necessary that you become comfortable evaluating and const...
...nt to invest some
additional time making sure you understand them.

boolean havingFun,amTired;
int  i,j;

havingFun= true;
amTired= false;
i= 0;
j= 10;

Given these variable declarations and initializations, do the following:

  1. By hand, calculate the value of each of the following boolean expressions. (Write your answers down).
  2. Construct a program to calculate each of the following boolean expressions.
  3. Compare your answers with the computer's answers. Reconcile any differences.
  4. Submit your complete assignment by email. In the comment header at the top of your program, identify the expressions that you calculated incorrectly on your first attempt. If you got them all correct on your first attempt then say so.

NOTE: One of the expressions is not a boolean expression. You will not be able to encode that one in your program. When calculating by hand, identify which expression is bogus. Here are the expressions to be evaluated:

  1. amTired
  2. i < 0
  3. j < i || j < 100
  4. i < j < 100
  5. !amTired || havingFun && i>10
  6. !havingFun || j >0 || amTired
  7. !(i>0 && !havingFun) || amTired


Quick Links