Coding a Quiz
I am attempting to make a quiz that tells you how many you got wrong.The only way I can think of is to make a new path of windows for every right or wrong answer.But even for a short quiz this would take a lot of time to do.Is there any other way to have a quiz give the number of correct answers at the end of the quiz?
create a boolean array and use LINQ magic.
[highlight=vb.net]
Dim numQuestions As Integer = 10 'for example, 10 questions
Dim correctAnswers(numQuestions - 1) As Boolean
'...do your testing here for example:
For i As integer = 0 to numQuestions - 1
'ask question "i"
correctAnswers(i) = checkAnswer("their answer")
Next i
'now to count all the correct answers.
Dim correct As Integer = correctAnswers.Where(Function(b As Boolean) b).Count()
MessageBox.Show("You got " + correct.ToString() + " answers out " + numQuestions.ToString() " correct!");
[/highlight]