1. Using Java
MINISTRY OF EDUCATION & HIGHER EDUCATION
COLLEGE OF SCIENCE AND TECHNOLOGY
KHANYOUNIS- PALESTINE
Lecture 6
Decision Making : Equality and Relational Operators
2. What is the decision ?
Equality and relational operators.
Precedence and associatively of operations
How to use if ?
Practice
Be care
Emank X Mezank
2Presented & Prepared by: Mahmoud R. Alfarra
3. For example, the condition "grade is greater
than or equal to 60" determines whether a
student passed a test.
3Presented & Prepared by: Mahmoud R. Alfarra
What is the decision ?
Note 5 applications demand the making decision
HW 5.1
4. Conditions in if statements can be formed by
using the equality operators and relational
operators.
Equality operators are used to check if two
operands are equals or not.
Relational operators are used to check if one
of two operands are greater or less than
another.
4Presented & Prepared by: Mahmoud R. Alfarra
Equality and relational operators
6. 6Presented & Prepared by: Mahmoud R. Alfarra
Precedence and associatively of operations
7. 7Presented & Prepared by: Mahmoud R. Alfarra
How to use if ?
If (condition)
{
/*Tasks will be executed
* if the condition true*/
}
condition
yesNo
If true
Executed
at all
8. Write a program to compare two numbers
and print the larger, smaller, equal or not.
8Presented & Prepared by: Mahmoud R. Alfarra
Example: Compare Integers
Write a program to calculate the summation,
multiple, division, subtraction and then compare
the results to print the larger, smaller, equal or notHW 5.2
9. 9Presented & Prepared by: Mahmoud R. Alfarra
Example: Compare Integers
Rewrite
this
program
using
another
values
HW 5.3
10. 10Presented & Prepared by: Mahmoud R. Alfarra
Forgetting the left and/or right parentheses for the condition
in an if statement is a syntax error the parentheses are
required.
Confusing the equality operator, ==, with the assignment
operator, =, can cause a logic error or a syntax error.
It is a syntax error if the operators ==, !=, >= and <= contain
spaces between their symbols, as in = =, ! =, > = and < =,
respectively.
Reversing the operators !=, >= and <=, as in =!, => and =<, is
a syntax error.