# True and false keycodes for game (Quiz / true or false game)

**URL:** <https://discourse.processing.org/t/true-and-false-keycodes-for-game-quiz-true-or-false-game/15884>\
**Category:** Coding Questions\
**Created:** [November 27, 2019, 3:40pm UTC](https://discourse.processing.org/t/true-and-false-keycodes-for-game-quiz-true-or-false-game/15884 "2019-11-27T15:40:19Z")\
**Posts on this page:** 1\
**Page:** 3

<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:** [December 20, 2022, 2:21pm UTC](https://discourse.processing.org/t/true-and-false-keycodes-for-game-quiz-true-or-false-game/15884/41 "2022-12-20T14:21:29Z")

</div>

The scores happen in this function here:

> [@Zayba](#):
>
> ```auto
> void checkAnswer(String answer, String correctAnswer) {
> 
> answer = answer.toLowerCase();
> correctAnswer = correctAnswer.toLowerCase();
> 
> if (question!=0) {
> 
> //Note: You could use .contains() instead.
> if (answer.equals(correctAnswer)) {
> 
> if ( correctAnswer.equals("False") )
> totalCorrect++;
> else totalWrong++;
> } else {
> if ( correctAnswer.equals("True") )
> totalCorrect--;
> else totalWrong--;
> 
> totalWrong=0+1;
> }
> }
> question++;
> }
> 
> ```

[Previous page](https://discourse.processing.org/t/true-and-false-keycodes-for-game-quiz-true-or-false-game/15884.md?page=2)
