a new user here... and I feel my code is wrong.
I'd like to ask for assistance since I am relatively new to the program of Greenfoot. The problem at hand is as stated in the question: I am receiving an "incompatible types" error when compiling my code and I can't seem to fix it regardless of any modification I do. The specific part of code where the problem lies is as follows:
public void answerValidation()
{
int ansCorrect = 0;
int ansIncorrect = 0;
for(int i = 0; i <= 10; i++)
{
answerArray[0] = array1[0] * array2[0];
if(answer != answerArray[0])
{
ansIncorrect = ansIncorrect + 1;
JOptionPane.showMessageDialog(null, array1[0] + "*" + array2[0] + "=" + answerArray[0]);
}
else
{
ansCorrect = ansCorrect + 1;
}
}
switch(ansCorrect)
{
case 10: JOptionPane.showMessageDialog(null, "Wow! You got all the questions right!");
break;
case ansCorrect>=8 && ansCorrect < 9: JOptionPane.showMessageDialog(null, "You scored" + ansCorrect + "out of 10. 80%-90% scored.");
break;
case ansCorrect >=6 && ansCorrect < 7: JOptionPane.showMessageDialog(null, "You scored" + ansCorrect + "out of 10. Keep practicing in Lv2 to improve.");
break;
case ansCorrect == 0 && ansCorrect < 6: JOptionPane.showMessageDialog(null, "You scored" + ansCorrect + "out of 10. Keep practicing in Lv1 to improve.");
break;
}
}
The compiling error states that it is located where it says "&& ansCorrect < 9", although I don't know how to fix it.
Any corrections/requests to see my code are welcome, and much thanks to those who help!