Wednesday, 2024-12-18, 8:39 PM

Welcome Guest | RSS

MainRegistrationLogin
Qbasic Home

Catalog categories
Qbasic Tutorial [31]

Rate my Site
Rate JPSor Site
Total of answers: 168

Main » Articles » Qbasic Tutorial

Chapter 12 - Qbasic Tutorial

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.



Source: http://jpsor.ucoz.com
Category: Qbasic Tutorial | Added by: JPSor (2009-02-26) | Author: JPSor
Views: 1808 | Rating: 0.0/0 |
Login

Qbasic Clock

Search

Visit my Friends

Who's Online

Total online: 1
Guests: 1
Resgistered: 0


Copyright MyCorp © 2024