How do I change the code....
if (yourAnswer = numberOne + numberTwo)
{
System.out.println("That is correct!");
counter = counter + 1;
}
else
{
System.out.println("That is incorrect!");
}
This does not seem to be working for me. Can anyone help me?. The debugger is saying:
RandomNumbersProgramThree.java:21: error: incompatible types: int cannot be converted to boolean".
You cannot associate a number with a Boolean value. A boolean is true or false, not a number, however you can create a variable that indicates if a certain number represents true or false. Is this your entire program? I would like to see what "yourAnswer", "numberOne", and "numberTwo" are stored. but for now I will write a pseudo-program to explain the theory.
This program will ask the user to input a number, for example the number "3". It will then compare that number to the two numbers you declares, "numberOne" which equals the value of one, and "numberTwo" which equals the value of two. Therefore, in the "IF" statement it says, "If (yourAnswer == (numberOne + numberTwo))" which means that 1 + 2 = 3, if the users answer is 3, then 3 = 3 and the result will come back as true.