I need help creating a code to calculate monetary change
이전 댓글 표시
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
Rik
2021년 9월 21일
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
2021년 9월 21일
Walter Roberson
2021년 9월 21일
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!