hi,
Your choice of variable names is confusing you :+)
You prompt for current balance, but store that value into
initialBalance
. On line 67, you use
currentBalance
which is zero, so that is why the answer is negative.
Also,
choice
stores the Item Price, which is misleading.
Line 60 is suspect, it should use an OR operator not AND.
If counter == 1,
currentBalance
is not updated (assigned a new value)
Why is counter incremented?
What is different about counter >= 2 ? Maybe you meant to calc with initial balance with 1, and current balance with 2 or greater ?
Investigate the
-=
,
+=
etc operators:
69 70 71 72 73
|
else if (counter >=2)
{
currentBalance -= (itemQuantity*choice);
cout << "\nYour new balance is: $" << fixed << currentBalance << "\n";
}
|
Investigate using a bool value when the user wants to quit, use this in conjunction with a while loop, instead of a do loop.
Hope all is well :+)