Computer Science Canada How to keep score in a quiz on turing? |
Author: | CookieMonster [ Sat Oct 19, 2013 11:42 am ] | ||||
Post subject: | How to keep score in a quiz on turing? | ||||
Hi I'm super new to turing and for an assignment for school, I have to create a multiple choice quiz, and I need to keep score on how the user did. For example if the user gets the question right, it adds 10 points to the score. My codes so far is:
I also need to incorporate a loop in to the assignment, how should i do that? Mod Edit: Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
|
Author: | Nathan4102 [ Sat Oct 19, 2013 11:52 am ] |
Post subject: | RE:How to keep score in a quiz on turing? |
Just below put"Correct", increment a score variable by your chosen amount. To add a loop, you could make an option to retake the quiz. |
Author: | Raknarg [ Sat Oct 19, 2013 11:58 am ] | ||
Post subject: | RE:How to keep score in a quiz on turing? | ||
|
Author: | hgrad98 [ Mon Oct 28, 2013 8:00 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
[syntax="turing"] var score : int var score := 0 if answer = correct then |
Author: | hgrad98 [ Mon Oct 28, 2013 8:04 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
var score : int score := 0 if answer = "correct" then put "You are correct!" score := score + 1 end if if answer = "wrong" then put "You are incorrect!" score := score + 0 end if ... and so on put "your total is: ", score you're welcome |
Author: | hgrad98 [ Mon Oct 28, 2013 8:05 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
sorry about the double post my computer went stupid and replied it while i was typing |
Author: | Zren [ Mon Oct 28, 2013 8:45 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
You should be using an else statement for the section where you're "wrong". Otherwise you're implying there are 4 different states rather than just 2. |
Author: | hgrad98 [ Tue Oct 29, 2013 4:43 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
it doesn't really matter though. it doesn't change it |
Author: | hgrad98 [ Tue Oct 29, 2013 4:49 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
and i meant + 10 not + 1 |
Author: | kim1590 [ Sat Nov 24, 2018 12:08 pm ] |
Post subject: | Re: How to keep score in a quiz on turing? |
i also need help i have a similar code but when the user gets the wrong answer once they get a second chance but for some reason after their second chance when they get it right it repeats the question MY CODE: loop %kim farni %variables var number1 : int var number2 : int var number3 : int var number4 : int var number5 : int var number6 : int var number7 : int var number8 : int var number9 : int var score : int score := 0 var numberoftries : int numberoftries := 0 var guess : int %setting ranges for variables randint (number6, 10, 15) randint (number7, 10, 15) randint (number8, 10, 15) randint (number9, 10, 15) %prints the question on screen put "your score is ", score put "you have tried ", numberoftries.. put " times" put "what is the answer to the following quetion?" put number6 .. put " x " .. put number7 %setting ranges for variables randint (number1, 1, 3) randint (number2, 4, 5) randint (number3, 6, 7) randint (number4, 8, 9) randint (number5, 10, 11) %prints on screen choices put " a) " .. put number1 put " b) " .. put number6 * number7 put " c) " .. put number3 put " d) " .. put number4 put " e) " .. put number5 get guess %gives users a chance to put in their guess %if the users puts the right answer then it says correct if guess = number6 * number7 then put "correct! the answer was ", number6 * number7 score := score + 1 numberoftries := numberoftries + 1 put "your score is ", score put "you have tried ", numberoftries.. put " times" end if %if the user puts in a bigger number than the answer then it shows incorrect and puts another story if guess > number6 * number7 then score := score + 0 numberoftries := numberoftries +1 put "you have tried ", numberoftries.. put " times" put "incorrect your score is now ", score put "the answer was ", number6 * number7 .. put " try again!" put number8 .. put " x " .. put number9 put " a) " .. put number4 put " b) " .. put number8 * number9 put " c) " .. put number1 put " d) " .. put number3 put " e) " .. put number5 get guess elsif guess < number6 * number7 then score := score + 0 numberoftries := numberoftries +1 put "you have tried ", numberoftries.. put " times" put "incorrect your score is now ", score put "the answer was ", number6 * number7 .. put " try again!" put number8 .. put " x " .. put number9 put " a) " .. put number4 put " b) " .. put number8 * number9 put " c) " .. put number1 put " d) " .. put number3 put " e) " .. put number5 get guess end if exit when guess = number6 * number7 end loop %put "your total is: ", score |
Author: | Insectoid [ Mon Nov 26, 2018 1:55 pm ] |
Post subject: | RE:How to keep score in a quiz on turing? |
What happens if you give the wrong answer for the 1st question, then for the 2nd question give the correct answer for the 1st question? Ie >What is 2x3? 4 >Wrong, what is 4x7? 6 What will the program do here? What is it supposed to do? |