PLEASE USE PYTHON SPYDER Your program must meet the followin

PLEASE USE PYTHON SPYDER

Your program must meet the following specifications:

1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 pennies.

2. Repeatedly prompt the user for a price in the form xx.xx, where x denotes a digit, or to enter ‘q’ to quit. 3. When a price is entered: a. If the price entered is negative, print an error message and start over requesting either a new price or to quit (indicated by entering a ‘q’).

b. Prompt for the number of dollars in payment. If the payment is insufficient, print an error message and reprompt for payment.

c. Next determine the coins to be dispensed as change. This calculation will depend on the amount to be dispensed and also on the number of coins left in the stock. For example, the least number of coins needed to make change of $1.30 is 6: 5 quarters and 1 nickel. But if there are only 3 quarters, 3 dimes, and 10 nickels left in the stock, then the least number is 11: 3 quarters, 3 dimes, and 5 nickels.

d. Print the numbers of the coins to be dispensed as change and their denominations. (Omit a denomination if no coins of that denomination will be dispensed.)

e. In case exact payment is made, print a message such as “No change.”

f. If the change cannot be made up with the coins remaining, print an error message and halt the program

4. Just before quitting, print the total amount (the number of dollars and number of cents) left in the stock.

Solution

pennies = 10

nickels = 10

dimes = 10

quarters = 10

quarters_spent = 0

dimes_spent = 0

nickels_spent = 0

pennies_spent = 0

print(\"\ Welcome to change-making program.\")

in_str = input(\"\ Enter the purchase price (xx.xx) or `q\' to quit: \")

while in_str.lower() != \'q\':

    dollar_str, cents_str = in_str.split(\".\")

    if in_str.lower() == \'q\':

        quit()

    in_int = int(float(in_str) * 100)

    if in_int < 0:

        print(\"Error: purchase price must be non-negative.\")

        in_str = input(\"\ Enter the purchase price (xx.xx) or `q\' to quit: \")

    if in_int > 0:

        payment = input(\"\ Input dollars paid: \")

        payment_int = int(float(payment) * 100)

        change = payment_int - in_int

        #determines if there payment input

        if payment_int < in_int:

            print(\"Error: Insufficient payment.\")

            payment = input(\"\ Input dollars paid: \")

            payment_int = int(float(payment) * 100)

            change = payment_int - in_int

        if change == 0:

            print(\"No change.\")

        #determines how many quarters, dimes, nickels, and pennies are left

while change >= 25 and quarters > 0:

        change -= 25

        quarters_spent += 1

        quarters -= 1

        while change >= 10 and dimes > 0:

            change = change - 10

            dimes_spent += 1

            dimes = dimes - dimes_spent

        while change >= 5 and nickels > 0:

            change = change - 5

            nickels_spent += 1

            nickels = nickels - nickels_spent

        while change >= 1 and pennies > 0:

            change = change - 1

            pennies_spent += 1

            pennies = pennies - pennies_spent

        if quarters == 0 and dimes == 0 and nickels == 0 and pennies == 0:

           print(\"Error: ran out of coins.\")

            quit()

        print(\"\ Collect Payment Below:\")

        if quarters_spent > 0:

            print(quarters_spent, \"Quarters\")

        if dimes_spent > 0:

            print(dimes_spent, \"Dimes\")

        if nickels_spent > 0:

            print(nickels_spent, \"Nickels\")

        if pennies_spent > 0:

            print(pennies_spent, \"Pennies\")

        print(\"\ Stock: \", quarters, \"Quarters, \", dimes, \" Dimes, \", nickels, \" Nickels, \", pennies, \" Pennies \")

      in_str = input(\"\ Enter the purchase price (xx.xx) or `q\' to quit: \")

        pennies = pennies

        nickels = nickels

        dimes = dimes

        quarters = quarters

PLEASE USE PYTHON SPYDER Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 p
PLEASE USE PYTHON SPYDER Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 p
PLEASE USE PYTHON SPYDER Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10 quarters, and 10 p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site