Back in Chapter 4 we saw a DO...LOOP that went forever. There
are a number of ways to make a loop stop. One way is to use
WHILE. This next program uses WHILE to make sure the program
will only go as long as Answer$ has the letter "y" in it.
INPUT "Enter the first number: ", A
INPUT "Enter the second number: ", B
PRINT "The answer is: "; A * B
INPUT "Would you like to do it again (y/n)? ", Answer$
LOOP WHILE Answer$="y"
The condition on the LOOP WHILE line is the same as
a condition we might use in an IF...THEN. In this case, we
check to see if Answer$="y", and if it does, we continue
looping. If it doesn't, we fall out of the loop and our
You can add this feature to any program. Try adding it
to the fortune teller.