Information Technology Reference
In-Depth Information
if zip-status > 0
error-msg = “zip file problem; program ending - press enter”
go to end-program
end-if
end-if
end-program: screen (24,1) erase screen (24,20) error-msg input
end
Everything should look familiar since we have no new keywords. The account
number file has been defined a bit differently, but it's still the same file. We're using a
new file that has three fields, the city, state and zip code. That's the zip code file. Any
read resulting in a not found record for either the account number or zip code file, will
produce an error message, but allow another try for input. A problem other than that ends
the program with an error message. Variables won't be displayed on the screen as
requested by Sly if there is a zip code problem other than a not found. That's because the
branch will be done to
end-program
first.
It's time to return to our brain challenge of the previous chapter. To begin with, if
you divide the tablets into 4 on each side of the scale, you will need three weighings, and
not two. So why not place three pills on each side of the scale. If they do balance, it
means that the poison pill is one of the two remaining so just put one each on the balance
and now you know which is the bad one. However, if the three versus three match results
in one side weighing more than the other, you know that the poison pill is on the side
with the heavier ones. From those three take any two and place them on the scale. If one
weighs more than the other, you have the culprit but if they weigh the same, the poison
thing is the pill you left out of the last three. Thus you have found the undesirable pill in a
mere two weighings.
Search WWH ::




Custom Search