2.1. Consider the following code: double balance; bool withdraw(double amount) { if (amount <= balance) { balance -= amo
Posted: Sun May 15, 2022 1:01 pm
2.1. Consider the following code: double balance; bool withdraw(double amount) { if (amount <= balance) { balance -= amount; return true; } else { return false; } } Is the withdraw operation idempotent? Why or why not? If not, how might you rewrite it so it is? Hint: How would we know if a particular withdrawal was being re-attempted as opposed to a separate, subsequent withdrawal?