I am a beginner in computer programming and need help with this problem: Create a script that prompts the user to provide the number of pennies, nickels, dimes, and quarters. Display back the value of the coins in dollars and cents.
Here is my code so far, everything is good except it doesn't properly display the number of cents left over. For example; if the total is $1.76 it will say "you have 1 dollar and 1 cent(s). Thanks so much for any tips/help.
def main():
pennies = int(input("Enter pennies:"))
nickels = int(input("Enter nickels:"))
dimes = int(input("Enter dimes:"))
quarters = int(input("Enter quarters:"))
print("You entered:")
print("\tPennies:" , pennies)
print("\tNickels:" , nickels)
print("\tDimes:" , dimes)
print("\tQuarters:" , quarters)
total_value = get_total(pennies, nickels, dimes, quarters)
dollars = get_dollars(pennies, nickels, dimes, quarters)
left_over_cents = get_left_over_cents(pennies, nickels, dimes, quarters)
print("Total =$" , total_value, sep="")
print("You have", dollars, "dollars and", left_over_cents, "cent(s)")
def get_total(pennies, nickels, dimes, quarters):
pennies = (.01 * pennies);
nickels = (.05 * nickels);
dimes = (.10 * dimes);
quarters = (.25 * quarters);
total_value = pennies + nickels + dimes + quarters
return total_value
def get_dollars(pennies, nickels, dimes, quarters):
total_value = get_dollars(pennies, nickels, dimes, quarters)
dollars = format(total_value // 1, ".0f")
return dollars
def get_left_over_cents(pennies, nickels, dimes, quarters):
total_value = get_dollars(pennies, nickels, dimes, quarters)
left_over_cents = total_value
return left_over_cents
main()