What will the expression give us if flour is 2 and sugar is 0?

A good answer might be:

The whole expression will be false, because && combines two falses into false.

flour >= 4 && sugar >= 2
 ---------          --------
   false   &&       false
      ---------------
          false 

Try out the Cookie Calculator

Here is a version of the cookie program. It is written in JavaScript so the input is from the web browser window, not from the DOS window. The statements in the true branch and the false branch are are for JavaScript (not for Java), and won't work in your Java programs. They put characters into a "text box" in the browser window.


How much flour do you have? 

How much sugar do you have? 

  if ( flour >= 4 && sugar >= 2 )
    input_form.answer.value = "Enough for cookies!"  // Put positive answer in a text box
  else
    input_form.answer.value = "sorry...."            // Put negative answer in a text box
  


Try the program out with various values of flour and sugar to check that you understand how AND works.

QUESTION 6:

Try the program with exactly enough flour and sugar. Does the program work?

Click Here after you have answered the question