-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdollar.py
27 lines (21 loc) · 1.45 KB
/
dollar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Get the user's income amount.
User_amount = float(input("Enter your income amount: ")) # Assign the value of User_amount to a variable amount
amount = User_amount
User_amount *= 100 # The amount is multiplied by 100 to convert the dollars into cents.
#Dollars are worth 100 pennies
Dollars = int(User_amount //100) # The amount of dollars is subtracted from the total amount and then the quarters are counted.
User_amount %= 100
#Quarters are worth 25 cents
Quarters = int(User_amount //25) # The amount of quarters is subtracted from the total amount and then the dimes are counted.
User_amount %= 25
#Dimes are worth 10 cents
Dimes = int(User_amount //10) # The amount of dimes is subtracted from the total amount and then the nickels are counted.
User_amount %= 10
#Nickels are worth 5 cents
Nickels = int(User_amount //5) # The amount of nickels is subtracted from the total amount and then the pennies are counted.
User_amount %= 5
#Pennies are worth 1 cent
Pennies = int(User_amount //1) # The program will print out the amount of dollars, quarters, dimes, nickels, and pennies in the inputted amount.
User_amount %= 1
print(f"Your amount {amount} consists of") # Print results
print(f"Dollars {Dollars}\nQuarters {Quarters}\nDimes {Dimes}\nNickels {Nickels}\nPennies {Pennies}")