The issue is that the original problem statement does not indicate what should be done if the withdrawal should
not fall below $5, and
AbstractionAnon and
kemort both interpreted it differently.
AA suggests that it is logical to simply approve the withdrawal.
kemort suggested otherwise, imposing no withdrawal in that case.
AA then said that
kemort missed the w≥$5 possibility.
kemort is now upset because he was represented as having missed the possibility.
The fact that the original problem statement did not specifically address the w≥$5 possibility does not remove it from needing special consideration. You still have three conditions:
- (balance - withdrawal) ≥ 5
- 0 ≤ (balance - withdrawal - service charge) < 4
- (balance - withdrawal - service charge) < 0
The actual number of actions to be taken depend on the (unspecified) requirements. But not knowing any better it is unsafe to eliminate any possibilities. I would amend
AA's original post as:
-
Approve Unknown
- Apply a service charge
- Deny
Since your program cannot function without knowing (you must either modify the user's balance or not), you can:
- ask for further specific instruction for the first condition
- assume that the withdrawal cannot be approved (as there is not enough specific information to do it) [kemort's response]
- assume that the withdrawal should be approved unmodified (this is the implied condition -- the requirements only speak on what to do for specific states of the unmodified withdrawal -- the unmodified withdrawal is implied). [AbstractionAnon's response]
The code to do it is a very easily nested if statement:
1 2 3 4 5 6
|
if (balance - withdrawal >= 5)
unknown;
else if (balance - withdrawal - 1 < 0)
deny
else
approve (balance - withdrawal)
|
Hope this helps.