Qbasicnews.com
April 04, 2020, 02:38:25 AM
 Pages: [1] 2 3
 Author Topic: help w/another assignment...  (Read 7762 times)
heavenraiza
Member

Posts: 80

 « 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
DO
CLS
END
END IF
IF num1 * num2 = answer THEN
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?!
 Logged

here are 10 types of people, those that understand binary & those that dont. . .
Diroga
Been there, done that

Posts: 1087

 « Reply #1 on: August 31, 2003, 03:46:38 PM »

sleep 1
 Logged
whitetiger0990
__/--\__

Posts: 2964

 « Reply #2 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
CASE 0: CLS : END
CASE num1 * num2: corwro\$ = "CORRECT"
CASE ELSE: corwro\$ = "WRONG"
END SELECT
PRINT "ANSWER " + corwro\$ + "!!!"
SLEEP 1
GOTO Start:
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
heavenraiza
Member

Posts: 80

 « Reply #3 on: August 31, 2003, 05:49:40 PM »

thanx diroga & wt. . .
 Logged

here are 10 types of people, those that understand binary & those that dont. . .
whitetiger0990
__/--\__

Posts: 2964

 « Reply #4 on: August 31, 2003, 07:14:09 PM »

you're welcome
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Ninkazu
Been there, done that

Posts: 1169

 « Reply #5 on: August 31, 2003, 07:16:08 PM »

Quote from: "whitetiger0990"

His welcome is what?

You ARE welcome, moron.
 Logged

am an asshole. Get used to it.
heavenraiza
Member

Posts: 80

 « Reply #6 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?
 Logged

here are 10 types of people, those that understand binary & those that dont. . .
whitetiger0990
__/--\__

Posts: 2964

 « Reply #7 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?
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Member

Posts: 82

 « Reply #8 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.
 Logged

heavenraiza
Member

Posts: 80

 « Reply #9 on: August 31, 2003, 08:47:42 PM »

 Logged

here are 10 types of people, those that understand binary & those that dont. . .
whitetiger0990
__/--\__

Posts: 2964

 « Reply #10 on: August 31, 2003, 08:52:01 PM »

Quote from: "heavenraiza"
\
hey hey wait for me
Code:
a\$ = "HI   COOL GOOD BRAVONEAT "
RANDOMIZE TIMER
CLS
PRINT RTRIM\$(MID\$(a\$, (INT(RND * 5)) * 5 + 1, 5))
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
whitetiger0990
__/--\__

Posts: 2964

 « Reply #11 on: August 31, 2003, 08:59:32 PM »

Quote from: "Ninkazu"
Quote from: "whitetiger0990"

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.
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Member

Posts: 82

 « Reply #12 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 .
 Logged

whitetiger0990
__/--\__

Posts: 2964

 « Reply #13 on: August 31, 2003, 09:04:47 PM »

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!
 Logged

[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
heavenraiza
Member

Posts: 80

 « Reply #14 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.
 Logged

here are 10 types of people, those that understand binary & those that dont. . .
 Pages: [1] 2 3