Say that you enter 9 for flour and 1 for sugar.

A good answer might be:

               
flour >= 4  true 

sugar >= 2  false 

Logical Operators

Here is part of the program again:

    // check that there are enough of both ingredients
    if ( flour >= 4 && sugar >= 2 )
      System.out.println("Enough for cookies!" );
    else
      System.out.println("sorry...." );
For you to have enough ingredients, both relational expressions must be true. This is the role of the && (and-operator) between the two relational expressions. The && requires that both
flour >= 4 
and
sugar >= 2 
are true before the entire expression is true. The entire question must be true in order for the true branch to execute.

The and operator && is a logical operator. A logical logical operator looks at true and false values and combines them into a single true or false.

QUESTION 4:

Look at the program. How will the monitor screen look if the user typed 6 for flour and 4 for sugar?

Click Here after you have answered the question