Computer Science Canada

How can I make the scores add up after each question?

Author:  thomasb [ Wed Mar 30, 2011 1:09 pm ]
Post subject:  How can I make the scores add up after each question?

I am making a trivia game which asks 20 questions, after each question that is correct it say you have won 1 point but i want it to say the number of points in total they've won

put "For each question you get correct you will win 1 point"
put "Don't mess up"
put "Press Any Button To Continue"

getch (key)
cls


put name, ", Rick Astley is never gonna..."
put "1) Give you up"
put "2) Let you down"
put "3) Run around"
put "4) Desert you"
put "5) Make you cry"
put "6) Say goodbye"
put "7) Tell a lie"
put "8) Hurt you"
put "9) Rick Astley is never gonna do any of these things!"

put "Please Input The Number Of Your Choice"
get answer1
cls

if answer1 = "9" then
score := +1
put "Good job! " ..
put name, " You Got This Question Right So Far You Have Won " ..
put score ..
put " points"
getch (key)
cls

elsif answer1 = "2" or answer1 = "3" or answer1 = "4" or answer1 = "5" or answer1 = "1" or answer1 = "6" or answer1 = "7" or answer1 = "8"

then
put "That is incorrect, next question"
end if

Author:  Tony [ Wed Mar 30, 2011 1:46 pm ]
Post subject:  RE:How can I make the scores add up after each question?

Quote:

score := +1

score(variable) assignment(operator) one(positive)

Author:  Raknarg [ Wed Mar 30, 2011 2:58 pm ]
Post subject:  RE:How can I make the scores add up after each question?

shouldn't it be score := score + 1 or score += 1? or are they all the same?

Author:  Tony [ Wed Mar 30, 2011 3:36 pm ]
Post subject:  RE:How can I make the scores add up after each question?

No, they are not the same -- that's why this question is being asked Smile

For this to even compile, the + must be interpreted as a unary operator (same as minus in -1 (negative one)). Which is the same as just 1.


: