I have created a change machine and the change function works well. There is a slight problem though as say I am meant to get £1.90 change it gives me 1 pound coin, 3 fifty pence coins and 9 twenties. I need to find a way to ensure that it gives the correct change using multiple denominations. How is this done?
How to make change values exclusive
Collapse
X
-
Tags: None
-
Here I have included the current code to give you guys something to work with. I also have a new requirement to make the value as multiples of 5 pence
Balance = Change Mod 100
If Balance >= 0 Then
Pounds = (Change - Balance) / 100
Balance = Change
End If
txtPounds = Pounds
Balance = Change Mod 50
If Balance >= 0 Then
Fifties = (Change - Balance) / 50
Balance = Change
End If
txtFifties = Fifties
Balance = Change Mod 20
If Balance >= 0 Then
Twenties = (Change - Balance) / 20
Balance = Change
End If
txtTwenties = Twenties
Balance = Change Mod 10
If Balance >= 0 Then
Tens = (Change - Balance) / 10
Balance = Change
End If
txtTens = Tens
Balance = Change Mod 5
If Balance >= 0 Then
Fives = (Change - Balance) / 5
Balance = Change
End If
txtFives = Fives -
Never mind guys. I solved the problem myself. Multiples of five was a simple mod function and I had some variables the wrong way roundComment
Comment