java - Not sure what i'm doing wrong here (Boolean flag) -


There is a snippet of my code for assignments. I can not see the boolean flag to work properly. When I try to understand it, every name is missed or no name is missing. Mike or Diana should be given a rebate to clarify the name

  First string; // user's first name boolean discount = false; // flag, if the user is eligible for discount inch inch; Size of size of Pizza Four Crust type // Size; // code for the type of crust string crust; // Crust Double Price = 12.99; // Last Cost of Pizza Double TAX_RATE = .08; // Double sales tax rates; // amount of tax choice; // user's choice string input; // user input string topping = "cheese"; // number of topping int numbersofopting = 0; // Get the number of topping // Prompt user and first name system.out.println ("Welcome to Mike and Dian's Pizza"); System.out.print ("Enter your first name:"); FirstName = keyboard.nextLine (); Firstname == "Mike" || First name == "Diana" || First name == "Mike" || First name == "Diana" || First name == "Mike" || First name == "Diana") {discount = true; } If (discount = true) {cost - = 2.0; System.out.println ("You are eligible for a $ 2 discount."); First, to compare the strings, you  ==  

. You must use the string = IQ () method.
  if (first name == "mike" || first name == "diana"} first name = "mike" || first name == "diana" <== "Mike"} will be replaced with   

first name == "Diana")

  if (first name amble ("mike" First name. Ezell ("Diana") | First name.Ajel ("Mike") | First name. Azeel ("Diana") First name. Eagles ("Mike") | firstName.equals ("DIANA" ))   

However, as the comment on your basic question says, this is the whole string It would be better to either convert uppercase or lowercase, make less comparaisons or use equalsIgnoreCase () according to the comment.

You also need to change:

  if (discount = true)   

that true Specify the value of the variable discount ,

  (if discount <== true)   

or, the comment Accordingly,

  if (discount)    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -