hello to all my program creates a boolean for mailing and outputs "i brought my ride " when it is false i.e the customer will not like his purchase to be delivered and outputs "your purchase will be delivered " if it is true......
my problem is it outputs your purchase will be delivered even when the user inputs false

System.out.print("\nWould you like to your goods to be delivered?"
				 			+"\nEnter 1.for true mail it to me or "
				 			+"\nEnter 0. for false I brought my ride :");
		 boolean  mail_List = data.nextBoolean();


			if (mail_List = true)
			{

			System.out.print("\nYour purchases will be delivered");

			 	 }
			 	if (mail_List = false)
			 	 {
					 System.out.print("\n No thanks,I brought my ride");


		 }

Recommended Answers

All 2 Replies

what class is data an instance of? I assume it is the Scanner class?

remember, you're Scanner is trying to read a boolean, while you're having your user enter an integer. (don't really use Scanner myself, but this might be the issue.)
try with:

boolean mail_List = false;
if ( data.nextInt() == 1 )
 mail_List = true;
Member Avatar for hfx642

In your IF statements, use "==" instead of "=".
"==" is equality, "=" is assignment.

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.