The user runs the program and rates hunger, appearance, and aroma as 4, 6, and 9, respectively. What will the program print?

A good answer might be:

How hungry are you             (1-10):
4 
How nice does the cookie look  (1-10): 
6
How nice does the cookie smell (1-10): 
9
Buy the cookie!
Continue down the Mall. 

Arithmetic inside a Boolean Expression

The true-branch is executed because the sum of the ratings, 19, was greater than the threshold of 15:

(hunger + look + smell ) > 15

is true.

This boolean expression is more complicated than previous ones. The values of the variables hunger, look, and smell are added up, and it is the sum that is compared to the threshold, 15. Boolean expressions can get very complicated, and operator precedence rules will be needed to figure them out. This topic will be discussed in a later chapter. For now, remember that:

Arithmetic operators have higher precedence than relational operators, and so are done first.

The above Boolean expression could be written as:

hunger + look + smell  > 15

Since all the + are of higher precedence than the > the + will operate first.

QUESTION 4:

Evaluate each of the following Boolean expressions (to true or false):

12+4 > 16 5.2-1.2 <= 2.0+22*3-4 == 1+1