Does anyone knows here how to make a breakdown of money? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does anyone knows here how to make a breakdown of money?

Example input: 4568.25 Output: 1000: 4 pcs 500: 1 pc 200: 100: 50: 1 pc 20: 10: 5: 1 pc 1: 4 pc 25 cents: 1 pc 5 cents:

24th Sep 2019, 12:21 PM
Michael Gilbert Acuña
Michael Gilbert Acuña - avatar
1 Answer
+ 2
You can store all of the 'coins' in an array, and then keep executing it in a for loop, ising floor division to get how many coins you need, and then continur with the remainder.
24th Sep 2019, 12:30 PM
Airree
Airree - avatar