Esquieres Allan Francis M
Esquieres Allan Francis M
Objective:
FLOWCHART:
The first design of flowchart goes back to 1945 which was designed by John Von Neumann.
Unlike an algorithm, Flowchart uses different symbols to design a solution to a problem. It is another
commonly used programming tool. By looking at a Flowchartone can understand the operations and
sequence of operations performed in a system. Flowchart is often considered as a blueprint of a design
used for solving a specific problem.
Advantages of flowchart:
Operator Meaning
& AND A<B&B<C
| OR A<B|B<C
^ XOR (exclusive OR) A<B^B<C
|| Short-circuit OR A < B||B < C
&& Short-circuit AND A < B && B < C
! NOT NOT (A >B)
Sample
Step-1 Start
Step-4 SUM = A + B
Step-1 Start
ELSE
ENDIF
Step-4 Stop
Sample 3
Step-1 Start
Step-4 IF num2>num3 THEN print num2 is largest ELSE print num3 is largest ENDIF GO TO Step-6
Step-5 IF num1>num3 THEN print num1 is largest ELSE print num3 is largest ENDIF
Step-6 Stop
Relational and Logical Operators
In the terms relational operator and logical operator, relational refers to the relationships that
values can have with one another, and logical refers to the ways in which true and false values can be
connected together. Since the relational operators produce true or false results, they often work with
the logical operators. For this reason they will be discussed together here.
In Java, all objects can be compared for equality or inequality using = = and !=. However, the
comparison operators, <, >, <=, or >=, can be applied only to those types that support an ordering
relationship. Therefore, all of the relational operators can be applied to all numeric types and to type
char. However, values of type boolean can only be compared for equality or inequality, since the true
and false values are not ordered. For example, true > false has no meaning in Java.
For the logical operators, the operands must be of type boolean, and the result of a logical
operation is of type boolean. The logical operators, &, | , ^, and !, support the basic logical operations
AND, OR, XOR, and NOT, according to the following truth table:
As the table shows, the outcome of an exclusive OR operation is true when exactly one and only
one operand is true.
Here is a program that demonstrates several of the relational and logical operators:
class RelLogOps {
public static void main(String args[]) {
int i, j;
boolean b1, b2;
i = 10;
j = 11;
if(i < j) System.out.println("i < j");
if(i <= j) System.out.println("i <= j");
if(i != j) System.out.println("i != j");
if(i == j) System.out.println("this won't execute");
if(i >= j) System.out.println("this won't execute");
if(i > j) System.out.println("this won't execute");
b1 = true;
b2 = false;
if(b1 & b2) System.out.println("this won't execute");
if(!(b1 & b2)) System.out.println("!(b1 & b2) is true");
if(b1 | b2) System.out.println("b1 | b2 is true");
if(b1 ^ b2) System.out.println("b1 ^ b2 is true");
}
}
Activities: