Friday, November 3, 2017

Chapter 12 - The Fortune Teller


Here's a fun program that uses most of what we've learned so far to make a "Magic 8 Ball".
     CLS
     RANDOMIZE TIMER
     PRINT "I am the magical Fortune Teller."
     INPUT "Think of a question and press enter for your answer...", A$
     PRINT
     Answer = INT(RND * 5 + 1)
     SELECT CASE Answer
       CASE 1
         PRINT "Yes, definitely."
       CASE 2
         PRINT "Ask again, later."
       CASE 3
         PRINT "No way!"
       CASE 4
         PRINT "It is certain."
       CASE 5
         PRINT "Yes."
     END SELECT
As always, go ahead and customize it. Change "No way!" to "You bet!" to get a Fortune Teller that never says "No".

Adding CASEs

Go ahead and try adding a new fortune. You'll need to change
Answer = INT(RND * 5 + 1)
to
Answer = INT(RND * 6 + 1)

since there will be 6 fortunes now. Then you will need to add a "CASE 6" and a PRINT to print the new fortune.

1 comment:

  1. The information you've provided is useful because it provides a wealth of knowledge that will be highly beneficial to me. Thank you for sharing that. Keep up the good work. online fortune teller free

    ReplyDelete