Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: heavenraiza on August 31, 2003, 03:22:45 PM



Title: help w/another assignment...
Post by: heavenraiza on August 31, 2003, 03:22:45 PM
Here is another assignment i am working on for class.

"Create a program that tests a students ability to multiply 2 random numbers between 1 and 9. The program should continue until the student enters a 0 for the answer. It should display whether an answer is correct or not -- display the correct answer if it is wrong -- and the number of questions, number right, number wrong and percent correct. The use of  color is an added plus."

Here is what i have so far. . .

CLS
Start:
CLS
lowerbound = 1
upperbound = 9
RANDOMIZE TIMER
num1 = INT((upperbound - lowerbound + 1) * RND + lowerbound)
num2 = INT((upperbound - lowerbound + 1) * RND + lowerbound)
PRINT num1; num2
INPUT answer
DO
IF answer = 0 THEN
CLS
END
END IF
IF num1 * num2 = answer THEN
PRINT "ANSWER CORRECT!!!"
END IF
GOTO Start:
LOOP
END

The part i am working on now is to check if the output of the numbers showing on the screen is equal to the answer inputed by the user & to display ANSWER CORRECT. Its not working though. What am i doing wrong?!


Title: help w/another assignment...
Post by: Diroga on August 31, 2003, 03:46:38 PM
sleep 1


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 04:50:55 PM
well when you print it, it imediatly goes to start and uses CLS.
it does this SO fast you cant see "ANSWER CORRECT!!!"
sleep 1 works
here:
Code:
Start:
CLS
lowerbound = 1
upperbound = 9
RANDOMIZE TIMER
num1 = INT(upperbound * RND) + lowerbound
num2 = INT(upperbound * RND) + lowerbound
PRINT num1; num2
INPUT answer
SELECT CASE answer
CASE 0: CLS : END
CASE num1 * num2: corwro$ = "CORRECT"
CASE ELSE: corwro$ = "WRONG"
END SELECT
PRINT "ANSWER " + corwro$ + "!!!"
SLEEP 1
GOTO Start:


Title: help w/another assignment...
Post by: heavenraiza on August 31, 2003, 05:49:40 PM
thanx diroga & wt. . .


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 07:14:09 PM
you're welcome


Title: help w/another assignment...
Post by: Ninkazu on August 31, 2003, 07:16:08 PM
Quote from: "whitetiger0990"
your welcome

His welcome is what?

You ARE welcome, moron.


Title: help w/another assignment...
Post by: heavenraiza on August 31, 2003, 07:46:10 PM
another question. i want to randomly output string text to the screen everytime someone answers the question right or wrong. i need a hint on where to start, what function to use, etc?


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 08:17:46 PM
Quote from: "heavenraiza"
another question. i want to randomly output string text to the screen everytime someone answers the question right or wrong. i need a hint on where to start, what function to use, etc?

what do you mean? do you have a sample output?


Title: help w/another assignment...
Post by: LinkMaster Sab on August 31, 2003, 08:38:05 PM
Hmm... if you want random things like "Excellent!", "You're Good!", etc... then learn these techniques...

Random, like before...
x = INT(RND * blah) + 1

Select case, pretty much a set of if/else if with a single variable...
SELECT CASE x
CASE 1
PRINT "Blah"
CASE 2
PRINT "Weehee!"
END SELECT

That should be about all you need.


Title: help w/another assignment...
Post by: heavenraiza on August 31, 2003, 08:47:42 PM
thanx link. ..


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 08:52:01 PM
Quote from: "heavenraiza"
thanx link. ..
\
hey hey wait for me
Code:
a$ = "HI   COOL GOOD BRAVONEAT "
RANDOMIZE TIMER
CLS
PRINT RTRIM$(MID$(a$, (INT(RND * 5)) * 5 + 1, 5))


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 08:59:32 PM
Quote from: "Ninkazu"
Quote from: "whitetiger0990"
your welcome

His welcome is what?

You ARE welcome, moron.

just saw that... hey... your you're sounds the same. i spell it that same. What? i was typing a little fast.


Title: help w/another assignment...
Post by: LinkMaster Sab on August 31, 2003, 08:59:55 PM
Hehe, trying to be a little more complicated eh? Just because its shorter doesn't mean he'll understand it any better :).


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 09:04:47 PM
Quote from: "LinkMaster Sab"
Hehe, trying to be a little more complicated eh? Just because its shorter doesn't mean he'll understand it any better :).

i like it, if i can spend my time making it someone will spend their time understanding it.
well now that we're talking about it i first made a prog that was heads or tails. same basic concept, but that was a few weeks ago. then suddenly i toought of this way of having differnt lengths of words. i think im psychic... i thought of it before the problem came up!


Title: help w/another assignment...
Post by: heavenraiza on August 31, 2003, 09:06:00 PM
right. i could work w/what link gave me. i dont get what you gave me wt but youre right, if you give it to me. . .i'll figure out what it does. im still going to use the SELECT CASE though . . . lol.


Title: help w/another assignment...
Post by: LinkMaster Sab on August 31, 2003, 09:08:55 PM
Well, if you want to learn what he gave you, look up the help on MID$... it's simple really.


Title: help w/another assignment...
Post by: whitetiger0990 on August 31, 2003, 09:16:19 PM
Quote from: "heavenraiza"
right. i could work w/what link gave me. i dont get what you gave me wt.

i'll explain it...

'contains the words duh
a$ = "HI   COOL GOOD BRAVONEAT "

let's break the confusing line up
PRINT 'obvios
RTRIM$ 'removes the spaces on the right of the word
MID$ () 'ok l;et move INSIDE the mid
a$ 'obvios it's the string to fet the txt from
(INT(RND * 4)) * 5 + 1 ' the starting postion
5 ' is the amount of characters to get

'lets break this up
INT() 'duh
(RND * 5) * 5 + 1 'takes a rnd number 0 - 4 times it by 5; 0, 5, 10, 15, 20; then adds one; 1, 6, 11, 16, 21


that good?


Title: help w/another assignment...
Post by: Diroga on August 31, 2003, 09:49:03 PM
that was clever. but wont you get all the text on the left when it's 11, 16 ,21 ?


Title: help w/another assignment...
Post by: LinkMaster Sab on August 31, 2003, 11:34:17 PM
It may be clever, but my opinion is that it's overly complicated for the job needed to be done, and it limits the messages...


Title: help w/another assignment...
Post by: Diroga on August 31, 2003, 11:36:17 PM
nice avatar. ff1 was good. i got stuck in the  dwarf village. took me awail to get teh dynomite.


Title: help w/another assignment...
Post by: LinkMaster Sab on August 31, 2003, 11:37:59 PM
Hehe... not only FF1, but 8-bit theater. http://nuklearpower.com... really funny stuff  :lol:


Title: help w/another assignment...
Post by: Diroga on August 31, 2003, 11:57:39 PM
cool


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 12:04:11 AM
Quote from: "Diroga"
that was clever. but wont you get all the text on the left when it's 11, 16 ,21 ?

what do you mean. unless mistaken i believe to answer is no. run it and see

Quote from: "LinkMaster Sab"
It may be clever, but my opinion is that it's overly complicated for the job needed to be done, and it limits the messages...

limits messages?


Title: help w/another assignment...
Post by: LinkMaster Sab on September 01, 2003, 12:10:46 AM
Sure. Say you want messages with more then 1 word, or even more then 5 letters... you'd have to change the whole code to do that, rather then just a simple PRINT command.


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 12:19:09 AM
Quote from: "LinkMaster Sab"
Sure. Say you want messages with more then 1 word, or even more then 5 letters... you'd have to change the whole code to do that, rather then just a simple PRINT command.

no...
Code:
a$ = "I love cats I hate dogs Food is goodEat chicken "
RANDOMIZE TIMER
CLS
PRINT RTRIM$(MID$(a$, (INT(RND * 4)) * 12 + 1, 12))


Title: help w/another assignment...
Post by: LinkMaster Sab on September 01, 2003, 12:23:44 AM
Bah, still have to change two things. Sorry, was thinking differently.


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 12:45:21 AM
Quote from: "LinkMaster Sab"
Bah, still have to change two things. Sorry, was thinking differently.

hmm thinking differently...


Title: help w/another assignment...
Post by: LinkMaster Sab on September 01, 2003, 12:58:19 AM
Thinking in terms of my C++ program... grabs words in a string of words and returns em. Handy.


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 01:00:01 AM
Quote from: "LinkMaster Sab"
Thinking in terms of my C++ program... grabs words in a string of words and returns em. Handy.


???
what do you mean. how was it different?


Title: help w/another assignment...
Post by: oracle on September 01, 2003, 02:48:07 AM
Sorry to burst your high-and-almighty bubble whitetiger, but I already made the head/tail program using that method before you, look in the challenge section under that compo about shortest useful program ;)


Title: help w/another assignment...
Post by: LinkMaster Sab on September 01, 2003, 05:36:01 AM
It's different because it looks for spaces, not the # of letters.


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 10:35:19 AM
Quote from: "oracle"
Sorry to burst your high-and-almighty bubble whitetiger, but I already made the head/tail program using that method before you, look in the challenge section under that compo about shortest useful program ;)

so... i dont care anout that one


Title: help w/another assignment...
Post by: oracle on September 01, 2003, 06:43:33 PM
but white: you can't say it's your method! ;)


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 08:15:12 PM
Quote from: "oracle"
but white: you can't say it's your method! ;)

you cant say it's yours and plus i didn't.


Title: help w/another assignment...
Post by: oracle on September 01, 2003, 08:34:00 PM
You did not *strictly* say that it was your method, but you posted it as if it was yours, that's the tone I got from reading this thread. I can claim to have made it up, because I posted a solution to the shortest algorithm challenge a little while ago that used that method, but if you haven't see it then it's just coincidence.


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 08:39:22 PM
Quote from: "oracle"
You did not *strictly* say that it was your method, but you posted it as if it was yours, that's the tone I got from reading this thread. I can claim to have made it up, because I posted a solution to the shortest algorithm challenge a little while ago that used that method, but if you haven't see it then it's just coincidence.

no i havn't seen it but im sure someone else out there did it first. so it doesn't matter i beat you to posting it  :wink:


Title: help w/another assignment...
Post by: oracle on September 01, 2003, 08:41:23 PM
That's cool then ;)

Now... what was the subject of this thread? :lol:


Title: help w/another assignment...
Post by: whitetiger0990 on September 01, 2003, 08:43:41 PM
Quote from: "oracle"
That's cool then ;)

Now... what was the subject of this thread? :lol:

umm. someone needed help with... ah... lets see...multiplication answer guessy thingy and i brought up a shorter program and we started talking about  this. i think im not sure
 :lol: