我正在开发一个小程序,基本上只是表明我知道如何使用超类。除了我的布尔值外,一切都很好。它应该询问使用他们想注册的邮件列表。如果输入“是”,则布尔值应为真,如果输入“否”,则应为假。我的问题是,即使我输入“否”,它仍然注册为“是”,使布尔值变为真。请帮忙?(我希望这有点道理。)
import java.util.Scanner;
public class CustomerDemo
{
public static void main(String[] args)
{
String name;
String address;
String telephone;
int customerNumber;
String input;
boolean mail = false;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter your name: ");
name = keyboard.nextLine();
System.out.print("Enter your address: ");
address = keyboard.nextLine();
System.out.print("Enter your phone number: ");
telephone = keyboard.nextLine();
System.out.print("Enter your customer number: ");
customerNumber = keyboard.nextInt();
keyboard.nextLine();
System.out.print("Do you want to be on the mailing list (Yes or No): ");
input = keyboard.nextLine();
if (input.equalsIgnoreCase("yes")) {
mail = true;
}
Customer cust = new Customer(name, address, telephone, customerNumber, mail);
System.out.println("Hello " + cust.getName() + "!");
System.out.println("You are customer " + cust.getCustomerNumber() + ".");
if(mail = false){
System.out.println("You are not on the mailing list. ");
}
else {
System.out.println("You are on the mailing list. ");
}
}
}