Computer Science Canada Third question won't work |
Author: | qmanjr5 [ Thu Dec 03, 2009 9:43 am ] | ||
Post subject: | Third question won't work | ||
that's my code at the moment. If you run that, you should be able to get the first two questions, no problem. But when you get to the 3rd question, it'll say you got it wrong. Or maybe it's just my Turing...? Any help will be appreciated BY THE WAY: Don't say anything about my code, please. I know it's not the best |
Author: | apomb [ Thu Dec 03, 2009 10:59 am ] |
Post subject: | RE:Third question won\'t work |
I understand why you set your score to zero, but why do you initialize your answers when you just overwrite them with the user's input? The last question does not work because of spaces. Also, the same problem arises with the second question if you try entering "thirty three million" as the answer. |
Author: | DemonWasp [ Thu Dec 03, 2009 11:41 am ] | ||
Post subject: | RE:Third question won\'t work | ||
Your get calls are only getting the first "token" from your user's input. That is, if I enter the answer: Barack Obama then the variable you get back has "Barack" and the next time you get something, it will have the value "Obama". To fix this, you want to grab the whole line of input:
The :* on the end tells it to take all the input up to an <Enter> key. |
Author: | qmanjr5 [ Thu Dec 03, 2009 8:26 pm ] | ||
Post subject: | RE:Third question won\'t work | ||
So
By the way, apomb, would do I do to fix that? Just not set the variables any values? I believe I need to set the score to 0, don't I? |
Author: | Zren [ Thu Dec 03, 2009 9:03 pm ] | ||||
Post subject: | RE:Third question won\'t work | ||||
It's because your using answer1, answer2, answer3 as the same variables for user input, not for the correct answer to the questions. BTW, You don't need a new variable for each answer. Since it should be like
So you could use the same variable for the user's answer on each question. Since you don't need to remember the answers given for all the questions (or you might I dunno). |
Author: | apomb [ Fri Dec 04, 2009 8:41 am ] | ||
Post subject: | Re: RE:Third question won\'t work | ||
qmanjr5 @ Thu Dec 03, 2009 8:26 pm wrote: So
By the way, apomb, would do I do to fix that? Just not set the variables any values? I believe I need to set the score to 0, don't I? you should definitely set score to 0 yes, but the other variables are just overkill. like zren said, you need only one "answer" variable, and reuse it for each question, and as for getting input, follow demonwasp's example exactly. (you forgot some important punctuation) |
Author: | TheGuardian001 [ Fri Dec 04, 2009 9:04 am ] | ||
Post subject: | Re: Third question won't work | ||
On that note, only the second : was needed. The first is used to indicate getting information from a file.
In Turing, the : after the variable indicates that you want to read a certain number of characters, whatever comes after defines how many. * is used to read until the end of a line. |
Author: | qmanjr5 [ Fri Dec 04, 2009 11:27 am ] | ||
Post subject: | RE:Third question won\'t work | ||
So, I DON'T need the answer1 = "2" answer2 = "33,000,000" etc Could I do this?
And so I just put, for question 3, [syntax='turing"] get answer3 if answer3 = "barack obama" then correct [/syntax] |
Author: | apomb [ Fri Dec 04, 2009 11:34 am ] | ||
Post subject: | RE:Third question won\'t work | ||
you should really use the same concepts for each of your questions. i.e.
That is not actual turing but its close enough you should see what i mean when i say "the same concepts for each question" |
Author: | qmanjr5 [ Fri Dec 04, 2009 3:37 pm ] |
Post subject: | RE:Third question won\'t work |
D: I'm so confused ![]() I'll figure it out D: 'Thanks all, problem solved for now ![]() |