Ask Question
26 November, 06:22

You will need to complete the functions these functions: a. get_total This function takes in pennies, nickels, dimes, and quarters. it returns the value of the money sent in via parameters in dollars. b. get_dollars This function takes in pennies, nickels, dimes, and quarters. it returns the dollar portion of the money sent in via parameters. c. get_left_over_cents This function takes in pennies, nickels, dimes, and quarters. it returns the cents portion of the money sent in via parameters.

+5
Answers (1)
  1. 26 November, 09:07
    0
    penny = int (input ("Enter number of pennies: "))

    nickel = int (input ("Enter number of nickel: "))

    dime = int (input ("Enter number of dime: "))

    quarter = int (input ("Enter number of quarter: "))

    def get_total (penny, nickel, dime, quarter):

    total = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter)) / 100

    print (f"The total amount is {total}")

    def get_dollars (penny, nickel, dime, quarter):

    dollar = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter)) / / 100

    print (f"The dollar part is ${dollar}")

    def get_left_over_cent (penny, nickel, dime, quarter):

    cent = ((1 * penny) + (5 * nickel) + (10 * dime) + (25 * quarter)) % 100

    print (f"The left over cent is {cent} cents")

    get_total (penny, nickel, dime, quarter)

    get_dollars (penny, nickel, dime, quarter)

    get_left_over_cent (penny, nickel, dime, quarter)

    Explanation:

    In the United States, these coins have following values:

    Quarter = 25 cents

    Dime = 10 cents

    Nickel = 5 cents

    Penny = 1 cent

    The first line collect an input from the user, convert to integer and assign to penny.

    The second line collect an input from the user, convert to integer and assign to nickel.

    The third line collect an input from the user, convert to integer and assign to dime.

    The fourth line collect an input from the user, convert to integer and assign to quarter.

    Based on the above definition of penny, nickel, dime and quarter; we defined the various function.

    First the get_total function was defined and the total amount was calculated and assigned to total, then the total was output to the user.

    Then, the get_dollars function was defined and the dollar part was calculated through dividing the total by 100. (100 cents = $1). The dollar was also output to the user.

    Then, the get_left_over_cents function was defined and the cent was calculated by finding the remainder when the total is divided by 100 (cent = total % 100). The symbol "%" represent modulo and is used to find remainder of a division operation.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “You will need to complete the functions these functions: a. get_total This function takes in pennies, nickels, dimes, and quarters. it ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers