## Boolean Expressions

This chapter introduces relational and logical operators. It also discusses the use of these operators to write Boolean expressions.

Answer:No. You need 4 cups of flour and 2 cups of sugar. Now you have more than enough flour, but not enough sugar, so you can't follow the recipe.

In order to bake cookies two things must both be true:

• You must have 4 or more cups of flour.
• You must have 2 or more cups of sugar.

If just one of these is false, then you do not have enough ingredients. Here is a simulation of the cookie program. Enter some values for sugar and flour and see if you can bake cookies. Use only integers as input.

How much flour do you have?
How much sugar do you have?

if ( flour >= 4 && sugar >= 2 )
else
System.out.println( "sorry...." );



The symbol && means AND. The if statement asks a question with two parts:

if ( flour >= 4 && sugar >= 2 )    ----------     ----------    flour part      sugar part

Each part is a relational expression. A relational expression is a type of boolean expression that uses a relational operator to compute a true or false value.

The entire expression between parentheses is also a boolean expression. A boolean expression is often composed of smaller boolean expressions. This is similar to human language where compound sentences are made from smaller sentences.

Question 3:Say that you enter 9 for flour and 1 for sugar. What value (true or false) does each part give you?              flour >= 4  sugar >= 2
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}