Magic 8-ball: Difference between revisions

Content added Content deleted
(Added solution for Action!)
(Magic 8-ball in various BASIC dialents)
Line 459: Line 459:
?
?
</pre>
</pre>


=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|QBasic}}
<lang BASIC256>dim answer$(20)
answer$[0] = "It is certain."
answer$[1] = "It is decidedly so."
answer$[2] = "Without a doubt."
answer$[3] = "Yes - definitely."
answer$[4] = "You may rely on it."
answer$[5] = "As I see it, yes."
answer$[6] = "Most likely."
answer$[7] = "Outlook good."
answer$[8] = "Yes."
answer$[9] = "Signs point to yes."
answer$[10] = "Reply hazy, try again."
answer$[11] = "Ask again later."
answer$[12] = "Better not tell you now."
answer$[13] = "Cannot predict now."
answer$[14] = "Concentrate and ask again."
answer$[15] = "Don't count on it."
answer$[16] = "My reply is no."
answer$[17] = "My sources say no."
answer$[18] = "Outlook not so good."
answer$[19] = "Very doubtful."

print "Q to quit."
while True
input string "What would you like to know? ", question$
if upper(question$) = "Q" then exit while
print answer$[int(rand * answer$[?])]
print
end while
end</lang>

==={{header|QBasic}}===
{{works with|QBasic}}
{{works with|QuickBasic|4.5}}
<lang QBasic>DIM answer$(19)
FOR i = 0 TO UBOUND(answer$): READ answer$(i): NEXT i
RANDOMIZE TIMER

PRINT "Q to quit."
DO
INPUT "What would you like to know? ", question$
IF UCASE$(question$) = "Q" THEN EXIT DO
PRINT answer$(INT(RND * UBOUND(answer$)))
PRINT
LOOP
END

DATA "It is certain.","It is decidedly so."
DATA "Without a doubt.","Yes – definitely."
DATA "You may rely on it.","As I see it, yes."
DATA "Most likely.","Outlook good.","Yes."
DATA "Signs point to yes.","Reply hazy, try again."
DATA "Ask again later.","Better not tell you now."
DATA "Cannot predict now.","Concentrate and ask again."
DATA "Don't count on it.","My reply is no."
DATA "My sources say no.","Outlook not so good."
DATA "Very doubtful."</lang>

==={{header|True BASIC}}===
{{trans|QBasic}}
<lang qbasic>DIM answer$(20)
FOR i = 1 to ubound(answer$)
READ answer$(i)
NEXT i
DATA "It is certain.", "It is decidedly so."
DATA "Without a doubt.", "Yes – definitely."
DATA "You may rely on it.", "As I see it, yes."
DATA "Most likely.", "Outlook good.", "Yes."
DATA "Signs point to yes.", "Reply hazy, try again."
DATA "Ask again later.", "Better not tell you now."
DATA "Cannot predict now.", "Concentrate and ask again."
DATA "Don't count on it.", "My reply is no."
DATA "My sources say no.", "Outlook not so good."
DATA "Very doubtful."

RANDOMIZE
PRINT "Q to quit."
DO
INPUT prompt "What would you like to know? ": question$
IF ucase$(question$) = "Q" then EXIT DO
PRINT answer$(int(rnd*ubound(answer$)))
PRINT
LOOP
END</lang>

==={{header|Yabasic}}===
{{trans|QBasic}}
<lang yabasic>dim answer$(19)
for i = 0 to arraysize(answer$(),1): read answer$(i): next i

print "Q to quit."
do
input "What would you like to know? " question$
if upper$(question$) = "Q" then end : fi
print answer$(int(ran(arraysize(answer$(),1))))
print
loop

data "It is certain.","It is decidedly so."
data "Without a doubt.","Yes – definitely."
data "You may rely on it.","As I see it, yes."
data "Most likely.","Outlook good.","Yes."
data "Signs point to yes.","Reply hazy, try again."
data "Ask again later.","Better not tell you now."
data "Cannot predict now.","Concentrate and ask again."
data "Don//t count on it.","My reply is no."
data "My sources say no.","Outlook not so good."
data "Very doubtful."</lang>



=={{header|C}}==
=={{header|C}}==