I am trying to make a program that determines whether a statement is true or false

I have this so far:

public static void main(String[] args)
	{
		int w=2,x=3,y=4,z=5;
		boolean expression;
		expression = (w<=x)&&(z>=y); 
		if(expression == true);
			System.out.println("true");
		if(expression == false);
			System.out.println("false");
		
	}

...but all it prints out is true and false

any help?

Recommended Answers

All 2 Replies

Made this change:

public static void main(String[] args)
	{
		int w=2,x=3,y=4,z=5;
		boolean expression;
		expression = (w<=x)&&(z>=y); 
		if(expression == true)
			System.out.println("true");
		if(expression == false)
			System.out.println("false");
		
	}

move the ";" after if(.....)

Hope it helps

Made this change:

public static void main(String[] args)
	{
		int w=2,x=3,y=4,z=5;
		boolean expression;
		expression = (w<=x)&&(z>=y); 
		if(expression == true)
			System.out.println("true");
		if(expression == false)
			System.out.println("false");
		
	}

move the ";" after if(.....)

Hope it helps

thanks man, its always something simple i miss...duh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.