the new user is here ... and I feel my code is wrong.
I would like to ask for help since I'm relatively new to Greenfoot. The problem is as stated in the question: I get an "incompatible type" error when compiling my code, and I cannot fix it regardless of any changes I make. The specific part of the code where the problem is located 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 compilation error indicates that it is where it says "& & ansCorrect <9", although I do not know how to fix it.
Any corrections / requests to see my code are welcome, and thanks very much to those who help!