mardi 5 mai 2015

Android If Statement Not Evaluating as Expected

I have the following If statement:

private boolean NextLevel(int intCorrectAnswers, int intNumberOfQuestionsAsked){
        if(intNumberOfQuestionsAsked>=20 && ((intCorrectAnswers / intNumberOfQuestionsAsked)>=.8)){
            return true;
        } else {
            return false;
        }
    }

What I want is if the number of questions asked is at least 20 and the percentage correct is at least 80% then return true.

Stepping through the code, I am answering at least 46 questions and getting all but 1 correct and it always returns false. What am I missing?

Aucun commentaire:

Enregistrer un commentaire