0

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");


		 }
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by hfx642
0

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;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.