Java Reference
In-Depth Information
Chapter 4
Decision trees & Loops
Suppose the problem statement given to you is to compute the same computation given in
the previous chapter but with a condition. The condition is that there is a leader among these
5 people and you need to compute only when this leader is at least 30 years old.
Let us write the computation program now.
private int a;
private int b.
private int c;
private int d;
a = 5;
b = 6.
c = 34;
If c >= 30 {
d = a*b,
system.out.println (d);.
}
Now we are telling the computer to compute 5 multiplied by 6 only when c (age of the lead-
er) is at least 30. For clarity at the Figure 1.5 as to how If-then decision tree works.
Search WWH ::




Custom Search