I created the format:
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)

    v_Dollars, v_Cents = divmod(total_value, 1)

    print("Total = ${:,.2f}".format(total_value))
    print("You have {:,} dollar(s) and {:.2f} cent(s)".format(int(v_Dollars), v_Cents))
# This format from the top^ was already created from "Start the assignemnt with this file":

# Completed the function for get_total:
# displayed the functions for pennies, nickels, dimes, and quaters.
# returning the value of the money sent to the via parameters in dollars. 
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

# Completed the function for get_dollars:
# displayed the functions for pennies, nickels, dimes, and quaters.
# returning the value of the money sent to the via parameters in dollars. 
def get_dollars(pennies, nickels, dimes, quarters):
    total_value = get_dollars(pennies, nickels, dimes, quaters)
    dollars = format(total_value // 1, "0.f")
    return dollars

# Completed the function for get get_left_over_cents:
# displayed the functions for pennies, nickels, dimes, and quaters.
# returning the value of the money sent to the via parameters in dollars. 
def get_left_over_cents(pennies, nickels, dimes, quaters):
    total_value = get_dollars(pennies, nickels, dimes, quaters)
    left_over_cents = int(100 *(total_value - dollars))
    return left_over_cents 

main()

Which is shown, however, I need to display dollar value and leftover cents with no decimal point. (for example, if the answer is 1.8, dollars should be 1 and leftover cents should be 80). I keep getting: total = $0.65

PLEASE HELP*****

Recommended Answers

All 2 Replies

Just a tip from my years working with accounting software. Skip storing your $3.50 as floating point and move to your lowest non-divisable unit or the penny. Then all display conversions are one way from pennies to dollars and cents and never from dollars to cents.

Where does dollars come from, and how is it different from total_value

def get_left_over_cents(pennies, nickels, dimes, quaters):
    total_value = get_dollars(pennies, nickels, dimes, quaters)
    left_over_cents = int(100 *(total_value - dollars))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.