Quiz with multiples choice - Beginner level

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 jb4xs Code above:

  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)

@jb4x Okay, will try once again

Thanks, hope to give you good news in few hours

1 Like

Well, I did not find an answer but I will :grin:

Just few question :

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

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

For example if you write this:

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.


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.

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

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

</> 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.