Created
November 25, 2019 19:17
-
-
Save kspillane/8c2b7302bc004f95c6d238674878cbf0 to your computer and use it in GitHub Desktop.
A Python script for breaking down the least denominations that could go into an arbitrary cash amount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total = float(input("Enter the total amount: ")) | |
change = [0,0,0,0,0,0,0,0,0,0] | |
if ( total % 100 ) < total: | |
change[0] = total // 100 | |
if (total % 100 % 50) < total: | |
change[1] = total %100 // 50 | |
if (total % 100 % 50 % 20) < total: | |
change[2] = total % 100 %50 // 20 | |
if (total % 100 % 50 % 20) < total: | |
change[3] = total % 100 % 50 % 20 // 10 | |
if (total % 100 % 50 % 20 % 10) < total: | |
change[4] = total %100 % 50 % 20 % 10// 5 | |
if (total % 100 % 50 %20 % 10 % 5) < total: | |
change[5] = total %100 % 50 % 20 % 10 % 5 // 1 | |
if (total % 100 % 50 %20 % 10 % 5 % 1) < total: | |
change[6] = total %100 % 50 % 20 % 10 % 5 % 1 // 0.25 | |
if (total % 100 % 50 %20 % 10 % 5 % 1 % 0.25) < total: | |
change[7] = total % 100 % 50 % 20 % 10 % 5 % 1 % 0.25 // 0.1 | |
if (total % 100 % 50 %20 % 10 % 5 % 1 % 0.25 % 0.1) < total: | |
change[8] = total %100 % 50 % 20 % 10 % 5 % 1 % 0.25 % 0.1 // 0.05 | |
if (total % 100 % 50 %20 % 10 % 5 % 1 % 0.25 % 0.1 % 0.05) < total: | |
change[9] = total % 100 % 50 % 20 % 10 % 5 % 1 % 0.25 % 0.10 % 0.05 / 0.01 | |
for i in range(len(change)): | |
change[i] = str(int(change[i])) | |
print("$"+str(total)+" breaks into:") | |
print("--==Bills==--") | |
print("Hundreds: "+change[0]) | |
print("Fifties: "+change[1]) | |
print("Twenties: "+change[2]) | |
print("Tens: "+change[3]) | |
print("Fives: "+change[4]) | |
print("Ones: "+change[5]) | |
print("--==Coins==--") | |
print("Quarters: "+change[6]) | |
print("Dimes: "+change[7]) | |
print("Nickels: "+change[8]) | |
print("Pennies: "+change[9]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment