Computer Science Canada Stupid question: Counters and Accumulators |
Author: | Angel [ Mon Jan 05, 2004 10:52 pm ] | ||
Post subject: | Stupid question: Counters and Accumulators | ||
I have to make up a code using counters and accumulators for a multiple choice quiz. The idea is to add a point for each correct answer. There are 10 questions and each of the users answers has been declared as an array. I haven't declared the actual answers or anything (I'm not sure if I'm supposed to). Here's an example of the code:
Say the answer for this question is 3 and I want to give 1 point to the person for getting the correct answer (if they get it). And I want to do that with the rest of my questions and in the end, display their total out of 10. I was told that I should use counters and accumulators, so can someone please give me the code? It will be greatly appreciated! Thanks guys. |
Author: | Tony [ Mon Jan 05, 2004 10:55 pm ] | ||
Post subject: | |||
it's something like
you could load questions/answers from a datafile or something |
Author: | Angel [ Mon Jan 05, 2004 11:04 pm ] | ||
Post subject: | |||
I'm not sure how to incorporate that into my program, so can I paste the program to you and you can make the code specifically for that program?
The array questions1 should technically be answers (the users answer that is). I'm not sure how to declare the actual answers, so can you help me with that too? You can just make them up. |
Author: | Thuged_Out_G [ Tue Jan 06, 2004 4:31 pm ] | ||
Post subject: | |||
im not sure what your saying but here is what i get
just do something like that for each question |
Author: | roer [ Tue Jan 06, 2004 5:58 pm ] | ||
Post subject: | |||
The easiest thing to do is too declare two variables, right and wrong. Or just right if you like.
Simple way to do it...or you can do it like tony and thugedoutG suggested |
Author: | shorthair [ Tue Jan 06, 2004 6:05 pm ] | ||
Post subject: | |||
What they are trying to tell you is to use count
that is the easiest aspect of count and that is exactly what you need. in your code do an if statment after you get the answer if ans1 = 1 then count := count + 1 else end if |
Author: | Angel [ Tue Jan 06, 2004 7:21 pm ] | ||
Post subject: | |||
I'm not quite sure that I understand. You said:
The thing is, the correct answer may not always be 1. Oh wait hold on I think I'm getting it, so after I get an aswer I should put that code upthere and the number of the correct answer? |
Author: | Thuged_Out_G [ Tue Jan 06, 2004 8:25 pm ] |
Post subject: | |
yuo will need an if statement for each question...it doesnt matter what the answer is if the answer is 1: if answer=1 then count +=1 else put "Wrong answer" end if if the answwer is 5: if answer=5 then count +=1 end if |
Author: | Angel [ Tue Jan 06, 2004 11:56 pm ] |
Post subject: | |
You guys are geniuses! Honestly, without you people I wouldn't have been able to do this ISP! Thanks, you've really helped! Just one more thing: I wanna make a table that says the number of the question, then the user's answer, then the correct answer, the number of points they received for each answer and then the total also converted to %? Anyone have any ideas? |
Author: | Tony [ Wed Jan 07, 2004 8:59 am ] | ||
Post subject: | |||
using string spacing. Such as
the :number will make the string atleast that long (it will not shorten it if the string is longer). Very useful for text alignment and making text tables. |