Unit III Talking Points—Boolean/Conditional Expresions

CS 1130 Visual Basic—Fall 2016 (Days 10-12)

Day 10 — Introduction;   CD-IIa

Logistics

CD-IIa was postponed until next Tuesday (next class period)

Ready for Unit II Competency Demo?

Are there any questions about the Unit II practice items or the sample competency demo?

Boolean Data & Operators—Conditional Expressions

In past discussion we have mentioned the "types" of data. Mostly data is either numeric or string in type. But there is a third type that is also critical or required for programming. Boolean data allows us to ask questions about the data and to make decisions based on the answers to our questions. But, we can only ask yes or no questions. Questions that can be answered as true or false

We want to ask questions such as:

But we cannot ask the questions like that. We have to represent them in a way the computer can understand. We do that by constructing Boolean expressions.

As with the numeric and string expressions, Boolean expressions will make use of literals, variables, operators, properties, and functions. As a matter of fact the expressions we have already learned about will or can be part of a Boolean expression.

Boolean expressions produce a value of true or false. Often this is done by comparing two values, e.g., first greater than second, value #1 equal to value #2, age less than 21, etc. Sometimes we want to examine several conditions, e.g., height greater than 48 inches and weight greater than 60 pounds. There are operators that allow us to do that also.

We construct Boolean using:   literals,   variables,   property values,   numeric and string (data) operators (+ - * / ^ Mod &),   relational operators (< <= >= > = <>),   logical operators (And Or Not),   and parentheses. You also need to be thinking about how to evaluate the expression — how the computer will "calculate" the result. Questions/Comments?

When evaluating Boolean expressions do the data expression values first, then the relational, then the logical. The precedence/order of operations is:

Some Examples

Next Time

Day 11 — Work on Unit III learning activity;   CD-IIa

Logistics

Unit III Questions

Unit II Competency Demo

Next Time

Day 12 — Share results of Unit III practice items

Logistics

Unit III Questions

Questions about the Unit III practice/learning activity items?

Solution Sharing

Next Time

Day 13 — review Unit II CD;   CD III

Logistics

Unit II CD.1.a Review

Unit III Questions

(if time) Unit IV — Conditional Execution

(at ≈ 3:10) Unit III Competency Demo

Next Time