mercredi 6 janvier 2016

Comparing == and != with If else in java

I am making a math addition program for my sister and I am new so I want to start small. I want to check for the correct answer because it asks you 5+6 or some random questions like that and waits for you to answer and i want it to compare your answer to the correct one

if (yourAnswer.equals (realAnswer)) {
        System.out.println("Correct");
    }
    else if (!realAnswer.equals (yourAnswer)) {
        System.out.println("Incorrect");
    }

Aucun commentaire:

Enregistrer un commentaire