# Chapter 5 200.docx

34 views2 pages 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
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
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

# Get access

\$10 USD/m
Billed \$120 USD annually
Homework Help
Class Notes
Textbook Notes