25 Apr 2012

School

Department

Course

Professor

For unlimited access to Class Notes, a Class+ subscription is required.

Chapter 5

Boolean Value: true or false

Relational Operators

< less than: 5 < 6

> greater than: m > n

<= less than or equal: 5<=(a+1)

>= greater than or equal: a>=7

== equals: (a+1) == (b+1)

!= not equals: 5!=6

Precedence

1) Brackets

2) Multiplication, Divison, Remainder

3) Addition, Subtraction

4) <, <=, =, >=, >, !=

IF & ELSE statements

if (<TEST>)

then <statement s1>

else

<statement s2)

Compound Statements

-using char variables

Example:

Student pass/fail and message program

char result;

if (mark >= 40)

result='P';

else

{

result=F;

System.out.println("Try again!");

}

**When you develop a branch that will need one or more statments you need curly brackets because it

causes the system to treat the gruop of statements as if their one

Java Logical Connectives

&& AND: p&&q is true if and only if p is true and q is true

|| OR : p||q is true if p or q or both are true

false + false = false

false + true = true

true + false = true