My quiz has 5 questions. If I get 4/5 correct I would expect the score to be 80% but the calculation is showing 85%.
The relevant code:
public void OnAnswerSelected(int index)
{
hasAnsweredEarly = true;
DisplayAnswer(index);
SetButtonState(false);
timer.CancelTimer();
scoreText.text = "Score: " + scoreKeeper.CalculateScore() + "%";
if (progressBar.value == progressBar.maxValue)
{
isComplete = true;
}
}
public int CalculateScore()
{
return Mathf.RoundToInt( correctAnswers / (float)questionsSeen * 100);
}
I’ve checked the correctAnswers and questionsSeen values at the end and they are showing as 4 and 5.
Update: The end screen is actually showing 85% regardless of my true score.
Any thoughts?
Kevin