Chapter 5 200.docx

34 views2 pages

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
Unlock document

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

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class