Help: boolean expressions
807606Mar 14 2007 — edited Mar 14 2007This might be a dumb question but Im new to Java and i have no idea what to do.
I'm trying to make the line (! i || q) && (i || ! q) to work but keep on getting a error saying :
G:\CSCI 120\CW\CW_8.java:23: operator ! cannot be applied to int
System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");
^
G:\CSCI 120\CW\CW_8.java:23: operator ! cannot be applied to int
System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");
^
G:\CSCI 120\CW\CW_8.java:23: operator && cannot be applied to java.lang.String,java.lang.String
System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");
^
how can i fix this?
this is the code i hav so far:
public class CW_8
{
public static void main(String[] args)
{
System.out.println("i" + " " + "q" + " " + "((!i || q) && (i || !q)");
{
int i;
int q;
for (i=0; i <= 1; i++)
for (q=0; q <= 1; q++)
{
System.out.println(i + " " + q + " " + (! i || q) && (i || ! q) + " ");
}
}
}