Qbasicnews.com

Full Version: help w/another assignment...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
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?!
sleep 1
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:
thanx diroga & wt. . .
you're welcome
Quote:your welcome
His welcome is what?

You ARE welcome, moron.
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?
Quote: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?
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.
thanx link. ..
Pages: 1 2 3 4