# Quiz with multiples choice - Beginner level

**URL:** <https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258>\
**Category:** Coding Questions\
**Created:** [April 14, 2019, 10:23am UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258 "2019-04-14T10:23:19Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 14, 2019, 4:41pm UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/21 "2019-04-14T16:41:06Z")

</div>

how many questions are you planning to do? 4 or 30?

You could store the right answer (1 or 2) for each question in an int array named `answer` similar to question array in [jb4x](https://discourse.processing.org/u/jb4x)s Code above:

```auto
  correctAnswer[0] = 1; 
  correctAnswer[1] = 2;
  correctAnswer[2] = 2;
  correctAnswer[3] = 1;

```

**Your check for the score**

Then check

check if 1 has been pressed

`if(key=="1" && answer[qNb] == 1) score += qNb+1;`

check the same for “2”

(pitfalls included)

---

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 14, 2019, 4:51pm UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/22 "2019-04-14T16:51:30Z")

</div>

@jb4x Okay, will try once again

Thanks, hope to give you good news in few hours

---

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 14, 2019, 5:33pm UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/23 "2019-04-14T17:33:37Z")

</div>

Well, I did not find an answer but I will 😁

Just few question :

Why do I have to link q1 to point ? ( “text(q1[point], 150, 150);” )

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [April 14, 2019, 5:41pm UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/24 "2019-04-14T17:41:48Z")

</div>

q1 is an array of String. You can access individual object of an array by using those brackets: `[]`

For example if you write this:

```auto
String[] myStrings = {"aaa","bbb","ccc"}

```

you are creating an array of String called `myStrings` that has 3 elements in it.

`myStrings[0]` will give you `"aaa"`  
`myStrings[1]` will give you `"bbb"`  
`myStrings[2]` will give you `"ccc"`

To answer your question better, the `point` variable has nothing to do with the place were you put it.  
In my example, I used the variable `qNb` that was keeping track of the question that was displayed.  
qNb = 1 when the first question needs to be displayed and so on.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 14, 2019, 5:42pm UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/25 "2019-04-14T17:42:12Z")

</div>

> [@EverybodyEthan](#):
>
> Why do I have to link q1 to point ? ( “text(q1[point], 150, 150);” )

??

point is just how he named his variable.

`qNb` is the same but a better name

qNb = `0` when the first question needs to be displayed and so on.

---

<div class="post-metadata">

**Author:** ![light](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@light](https://discourse.processing.org/u/light)\
**Post date:** [May 9, 2019, 7:23am UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/26 "2019-05-09T07:23:20Z")

</div>

i have add radio button 1,2,3,4 but dont know how to perform operation n them in processing 3  
like if 1 is selected print one

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [May 9, 2019, 8:14am UTC](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258/27 "2019-05-09T08:14:46Z")

</div>

sorry, you need to show your running example code  
and not forget to format it correctly with  
[ctrl][t] in processing IDE  
and here in post editor use the

```auto
</> code tag

```

and that shows you  
```  
type or paste code here  
```  
where you have to put your code inside!

also more text needed,  
as i not think you will be able to make “radio button” without the use of a library,  
and so you have to check the examples for that library about that type of buttons usage.

[Previous page](https://discourse.processing.org/t/quiz-with-multiples-choice-beginner-level/10258.md?page=1)
