Java Quiz
I have a quiz, everything works fine on the first
question, when I continue on to the secone question (i
have a continue button that resets all necessary
values) the application says the users answer is Wrong
even though it isn't. I even put message box's on the
Validate Answer function and it shows me that the
users input and the actual answer are exactly the same
but for some reason when the strings are compared
FALSE is returned. The strange thing about it is it
works grand the first time.
Here's the Validate ander fucntion:
//compare users answer with chordName
public void verifyAnswer(String s){
String output = "";
//******test messages
JOptionPane.showMessageDialog(null, "s "+s);
JOptionPane.showMessageDialog(null,
"chordName "+chordName);
boolean answerVerify = chordName.equals(s);
String bool = String.valueOf(answerVerify);
JOptionPane.showMessageDialog(null, "boolean
"+bool);
///////////////////////////////////////////////
if(chordName.equals(s))
{
score++;
output ="Correct!";
String str = String.valueOf(score);
resultText.setText(output);
scoreText.setText(str);
}
else if(!chordName.equals(s)){
output = "Hard Luck.";
resultText.setText(output);
String str = String.valueOf(score);
scoreText.setText(str);
}
}
I appreciate the help if you can give any.
David Lundy

