NEVER MIND- IT WAS MY OWN DUMB MISTAKE, CONFUSED THE VARIABLES
I have the following while loop:
while (((pi.getFunds() - rmiPrice) > 0) && (rmi.getInventory() > 0))
{
}
pi.getFunds()
is a double that represents how much money a fictional object (pi) has, rmiPrice
is a double that represents a price of a product (rmi) that pi wants to buy. rmi.getInventory
checks how much rmi is in the inventory- what I'm trying to do is this- while pi can afford to buy 1 more rmi AND there is at least 1 rmi in inventory, execute what is in the while loop.
What seems to be happening instead is that the &&
is not being recognized as either the inventory or the funds are allowed to go below 0 as long as the other is positive- any idea what I'm doing wrong?
I've also tried this:
int rmiInv = rmi.getInventory();
double piFunds = pi.getFunds();
while (((piFunds - rmiPrice) > 0) && (rmiInv > 0)) {}
And tried playing around with the bracket combos
while ((piFunds - rmiPrice) > 0 && rmiInv > 0) {}
while (piFunds - rmiPrice > 0 && rmiInv > 0) {}
nothing seems to work,
Thank you!