I need help creating a code to calculate monetary change
Afficher commentaires plus anciens
What is the code to determine how to give change in the correct amount of bills and coins, minimizing the total number of items returned. With the amounts of money owed and given must be variable and based on user input.
3 commentaires
Rik
le 21 Sep 2021
This sounds like homework. What have you tried so far?
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).
Nicky ten Bosch
le 21 Sep 2021
Walter Roberson
le 21 Sep 2021
The difficulty of minimizing the number of coins returned depends upon the list of values of the coins.
The UK monetary system uses denominators that are 10^N times {1, 2, 5} -- so for example, 1 pence, 2 pence, 5 pence, 10 pence, 20 pence, 50 pence, and so on. That system allows you to use the "greedy" algorithm.
The US monetary system, which has 1 cent, 5 cent, 10 cent, 25 cent, 50 cent (seldom seen), and $1 . The "greedy" algorithm does not work with US coins.
Réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!