Back to the
Subject
Look at line
60
very carefully. You
have
seen
every symbol
there before
—
but is there
something different
about how
they
are
arranged?
Hmmmm?
Ah yes
—
the parentheses. They are the tip-off. There has been (until now)
no reason
at
all
to
enclose something like
A=l
in parentheses.
When you come across a pair of parentheses
enclosing
an
=
sign, a
),
a
(
(or
a combination
of
these), you know logical math is being
used. (Whew
—
that's simple
enough!)
Having
used the
*
(which you know means AND) now it will all make sense.
EXERCISE
24-1
:
Using the above program as a model, and the
"OR
logic"
seen in Figure
2,
write a program which will report Bessie's status as determined by the
position
of Gates
X, Y and Z.
Teacher's
Pet
Here is a simple program which uses >instead of the equals sign in a logical
test. The
student
passes if he or she
has
a
final
grade over
60
OR a midterm grade over
70
AND a homework
grade over 75, Enter the program, RUN it a few times, and see how efficiently
the
logical
OR
and logical AND
tests
work
in
the same
program line
(40).
10 INPUT "FINAL GRADE" ;F
20
INPUT
"MIDTERM GRADE " ;M
30
INPUT " HOMEWORK GRADE " ;H
40 IF (F>60)
+
((M>70)
*
CH>75))
THEN
70
50
PRINT "FAILED"
60
END
70 PRINT "PASSED"
Does
this give you some idea
of
the
power
and convenience
of logical
math? The
actual
grade numbers could, of course,
be
set
at any
level.
149