0

The program keeps track of the product and quantity of the product in a do while loop and can only end if the user inputs the string "ZZZZ" and the integer 0. For example, inputting ZZZZ and 5 would not end the loop. But somehow it's still ending.

 while (!itemcode.equals("ZZZZ") && (quantity != 0));

The output that I'm getting is

Please enter the product code and quantity: ZZZZ 5

A105: 0    Price = 0.0
A207: 0    Price = 0.0
D671: 0    Price = 0.0
X111: 0    Price = 0.0
X902: 0    Price = 0.0
Total Price: $0.0

Which ends the loop but shouldn't.

1
  • 1
    Edit your question to a minimal, reproducible example. We can't help if we can't examine how you set itemcode and quantity, but computers do exactly what you tell them to do. Commented Mar 17, 2020 at 18:03

1 Answer 1

1

I think what you really want is this:

while (!(itemcode.equals("ZZZZ") && quantity == 0));
Sign up to request clarification or add additional context in comments.

Comments