Logic
Screenshot: 1
Description: An error occured while testing my CashReg program's change calculation process, where, if the change required had decimals above .5, the change recommended would come in negatives. I found this to be an error in the formula I used in order to remove values above a dollar from the change variable.
The formula, which was at the time:Instead of working with a double, since the rounding method I used had obvious holes, I instead used a variable casting method, changing the double-change into an integer, a process where it would automatically round down.
dblChange = dblChange - Math.round(dblChange)
Editted formula:This change in the formula promptly fixed the problem.
dblChange = dblChange - (int)dblChange;
No comments:
Post a Comment