|
Section 11: Branching and Looping170
|
|
Conditionals and Conditional Branches
|
|
Often there are times when you want a program to make a decision. For
example, suppose an accountant wishes to write a program that will
calculate and display the amount of tax to be paid by a number of
persons. For those with incomes of $10,000 per year or under, the
amount of tax is 17.5%. For those with incomes of over $10,000, the tax
is 22%. A flowchart for the program might look like this:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Stop to key in
income amount
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The conditional operations on your HP-41C are useful as program instructions
to allow your calculator to make decisions like the ones shown above. The ten
conditionals available in the HP-41C are shown below:
|
|
|
X=Y?
|
|
tests to see if the value in the X-register is equal to the value
in the Y-register.
|
|
|
X=0?
|
|
tests to see if the value in the X-register is equal to zero.
|
|