LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Amount of money to bills and coins

Solved!
Go to solution

Hi 

 

If I were to use a single Q&R in a for loop what would be the y input in the Q&R? It is changing 100, to 25 to 10.. etc

 

Here's my code. I used blackburnite's solution and it works perfectly well

0 Kudos
Message 11 of 14
(1,649 Views)

Here's what I would do. Fully scalable (e.g. if you want to add $10 and $20 bills, etc. later or to adapt to other currencies that uses different coin values).

(Of course the array of units needs to be sorted in descending order).

 

 

 

Download All
Message 12 of 14
(1,643 Views)
Solution
Accepted by topic author patomated

@patomated wrote:

Here's my code.


As I said, you should try to make the code more scalable. Avoid all these duplicate operations and use arrays as much as possible.

You had way too many cases. For example the change code works perfectly well if the change is zero, so there is no need to add yet another case, adding more layers and artifically complicating the code. You can also change the output tunnels to "use default if unwired". Now you can eliminate all these extra diagram constants.

 

Also, since you currently don't allow pennies, the input should be coerced to multiples of 5 cents.

 

You need to secure the inputs. Currently, people could insert nothing, select a negative number of items, and get lots of change for free!

 

Here's a quick rewrite to give you some ideas. (I don't like the popup, so I took that out. The LED seems sufficient. Vending machines don't have popups).

 

Modify as needed.

 

 

Message 13 of 14
(1,615 Views)

I cannot thank you enough for all the help you provide!

I had not realized that it works just the same if amount inserted equals the price

selecting a negative number also leads to getting free change

 

thanks for the simple code 🙂 much appreciated

0 Kudos
Message 14 of 14
(1,597 Views)