In your code you are asking "if item number is not equal to "A123" OR "A55" OR "B750" OR "C650", then do these things". So when you input "A55", program checks that is "A55" not equals to "A123" or "A55".... Ohh It's not equal "A123" so the condition is true.
If you change what you ask like this. "if item number is not equal to "A123" AND "A55" AND "B750" AND "C650", then do these things". So when you input "A55", program checks that is "A55" not equals to "A123" and "A55"... Ohh it's not "not equal" to "A55" so the condition is false. Example,
if (!"A123".equals(itemNumber) && !"A55".equals(itemNumber) && !"B750".equals(itemNumber) && !"C650".equals(itemNumber))
{
System.out.print("\nInvalid Item. Try again. ");
System.out.print("\nEnter an item number or END to exit: ");
itemNumber = keyboard.nextLine();
}
System.out.printf("\nThank you. %s", itemNumber);
Or you can change what you asking to something like this,
"if item number is equal to "A123" or "A55" or "B750" or "C650", then print "Thank You" and else do these things." It would be correct. Example,
if ("A123".equals(itemNumber) || "A55".equals(itemNumber) || "B750".equals(itemNumber) || "C650".equals(itemNumber))
{
System.out.printf("\nThank you. %s", itemNumber);
}
else{
System.out.print("\nInvalid Item. Try again. ");
System.out.print("\nEnter an item number or END to exit: ");
itemNumber = keyboard.nextLine();
}
||to&&!Arrays.asList("A123", "A55", ...).contains(itemNumber)