Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- salaries = [4352, 4536, 3224, 7686, 1243, 659, 633, 1324, 1254, 1678, 1160.64]
- payments = [[0 for x in range(15)] for x in range(len(salaries))]
- banknotes = [200, 100, 50, 20, 10, 5, 2, 1]
- coines = [50, 20, 10, 5, 2, 1]
- def doJob(i, salary):
- cents = 0
- if salary % 1 is not salary:
- cents = int((salary * 100) % 100)
- salary = int(math.floor(salary))
- for j, banknote in enumerate(banknotes):
- if salary >= banknote:
- payments[i][j + 1] = int(math.floor(salary / banknote))
- salary = salary % banknote
- for j, coin in enumerate(coines):
- if cents >= coin:
- payments[i][j + 9] = int(math.floor(cents / coin))
- cents = cents % coin
- for i, salary in enumerate(salaries):
- payments[i][0] = salary
- doJob(i, salary)
- toPrint = ""
- for payment in payments:
- toPrint += str(payment[0]) + ": "
- for i, value in enumerate(payment[1:9]):
- if value is not 0:
- toPrint += "{0} x{1}, ".format(banknotes[i], value)
- for i, value in enumerate(payment[9:]):
- if value is not 0:
- toPrint += "0.{0} x{1}, ".format(coines[i], value)
- toPrint += '\n'
- print(toPrint)
Advertisement
Add Comment
Please, Sign In to add comment