[java] Question for an online lab.
Ok, I hope once I get help on this I will think to myself how simple this really is. But I am trying this online learning to teach myself java, and I have come to a question:
Write an expression that evaluates to true if the integer variable x contains an even value, and false if it contains an odd value
so I wrote:
if (x % 2 = 0) // check if its even
{
s = true;
}
else
{
s = false;
}
and this website gives me an error saying:
-Unexpected identifiers: false, s, true
-Just write an expression -- not a statement!
-There is no need for an assignment operator here (=).
ok, so this is simple feedback, but maybe I just missed the section on writing simple expressions or something but I cant find it. Also note, variable s was declared earlier in the program as a boolean. The website gives their code implemented with my incorrect code and it looks like this:
Our Code 1 public class CTest {
2
3 public static void main(String[] args) {
4
5 int x=5;
6 boolean s;
7
8 s=
Your Code: 9 if (x % 2 = 0)
10 {
11 s = true;
12 }
13 else
14 {
15 s = false;
16 }
Our Code 17
18 ;
19 }
20 }
any help would be greatly appreciated for there are 5 other questions I cannot answer because Im just not understanding what they really want when they say expression I guess. Thanks in advance.
__________________
Jesus was a ruffies victim!
Dan 3:20
|