Decisions

# Decisions - CS 1054 Boolean Variables Decisions 1 Boolean...

This preview shows pages 1–3. Sign up to view the full content.

CS 1054 Decisions Intro to Object-Oriented Dev I Computer Science Dept Va Tech Jan. 2006 ©2006 Barnette, ND 1 Boolean Variables s Boolean type Java supports a simple data type specialized for representing logical values. boolean type variables can have either of two values: true or false The identifiers true and false are Java reserved words. s Assertions In Java, in order to ask a question, a program makes an assertion which is evaluated to either true or false at run-time. Example: in the Night&Day program assert whether “the moonPhase oval is below the ground?": boolean moonPhaseBelowGround; moonPhaseBelowGround = moonPhase.getY() > ground.getY(); Decisions Intro to Object-Oriented Dev I Computer Science Dept Va Tech Jan. 2006 ©2006 Barnette, ND 2 Relational Expressions s Boolean expressions can, generally, take one of two forms. The first is a relational expression, an expression (e.g., arithmetic) followed by a relational operator followed by another expression. For example: ( b * b - 4 * a * c ) > 0 s Relational operators relational operators can be used to compare two values of any of the built-in types discussed so far. Most mixed comparisons are also allowed, but frequently make no sense. Operator Meaning == equals != does not equal > is greater than >= is greater than or equal to < is less than <= is less than or equal to

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 1054 Decisions Intro to Object-Oriented Dev I Computer Science Dept Va Tech Jan. 2006 ©2006 Barnette, ND 3 Logical Expressions s A logical expression consists of a Boolean expression followed by a Boolean operator followed by another Boolean expression (with negation being an exception). s
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/30/2011 for the course ART 3514 taught by Professor Dhbannan during the Summer '03 term at Virginia Tech.

### Page1 / 6

Decisions - CS 1054 Boolean Variables Decisions 1 Boolean...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online