Question

Describe how you would create a Python program that calculates the exact amount of change to...

Describe how you would create a Python program that calculates the exact amount of change to give a customer in denominations of quarters, dimes, nickels, and pennies. For example, if the change is 79 cents, how many of each coin would be needed to give change?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As we know :

  • 1 quarter = 25 cents
  • 1 dimes = 10 cents
  • 1 nickels = 5 cents
  • 1 penny = 1 cent

So if we divide the change by -

  • 25 we get no. of quarters
  • 10 we get no. of dimes
  • 5 we get no. of nickels
  • 1 we get no. of pennies

In python, we will use the modulo operator to achieve this -

//(Floor division operator) = Divides and returns the integer value of the quotient. It-dumps the digits after the decimal.

%(modulo) = Divides and returns the value of the remainder.

#to get the input from the user
c=int(input('Please enter an amount between 0-99:\n'))
# //(Floor division operator) = Divides and returns the integer value of the quotient.
# It-dumps the digits after the decimal. 
# %(modulo) = Divides and returns the value of the remainder.
print(c//25, "quarters")
c = c%25
print(c//10, "dimes")
c = c%10
print(c//5, "nickles")
c = c%5
print(c//1, "pennies")
Add a comment
Know the answer?
Add Answer to:
Describe how you would create a Python program that calculates the exact amount of change to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python 3, Implement a program that directs a cashier how to give change. The program...

    In Python 3, Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount received from the customer. Display the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return. In order to avoid roundoff errors, the program user should supply both amounts in pennies, for example 526 instead of 5.26. Enter the amount due in pennies: 828 Enter the amount received from the customer in...

  • Write a C program that calculates exact change. In order to receive full credit, please remember...

    Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...

  • (In Python 3) Write a program with total change amount as an integer input, and output...

    (In Python 3) Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes So...

  • PLease help!!! how to type them in Python !!!! Python help!! THank you so much Problem...

    PLease help!!! how to type them in Python !!!! Python help!! THank you so much Problem 1: (20 points) Optimal change You will write a program that uses the // and % operators to figure out how to give change for a specified amount using the minimum number of coins (quarters, dimes, nickels, cents). The good news is that our currency is specifically designed to make this problem easy. For a given number of cents, first use as many quarters...

  • I made this C program to count change and make a slip saying the exact dollar...

    I made this C program to count change and make a slip saying the exact dollar and change amount given. every time I run the program it says the change given is 477256577 and i'm not sure what I have done wrong? #include<stdio.h> int main(void) { char first, last; int pennies; int nickels; int dimes; int quarters; int loonies; int change; int t_dollars; int t_cents; printf("Type in your 2 initials and press return> "); scanf("%c%c",&first,&last); printf("%c%c please enter in your...

  • Your program must meet the following specifications: 1. At program start, assume a stock of 10 nickels, 10 dimes, 10...

    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)...

  • C++ Write a program that helps a young student learn to make change. Use the random...

    C++ Write a program that helps a young student learn to make change. Use the random number generator to generate change amounts between1¢ and 99¢. Ask the user how many quarters, dimes, nickels and pennies they need to make that amount. Determine whether the coins specified by the user total the specified amount and give them feedback on their answer including whether they used the minimum or optimum number of coins to produce the amount. Sample output of a program...

  • Problem: Implement (in C) the dynamic program algorithm for the coin-change algorithm, discussed in class. Assume...

    Problem: Implement (in C) the dynamic program algorithm for the coin-change algorithm, discussed in class. Assume that the coins with which you make change are quarters, dimes, nickels and pennies. Thus you are going to set n = 4 in your program. The amount k for which you have to make change will be provided by the user and your program will return the minimum number of coins needed and also the break-up of the change in terms of the...

  • I need to change this python program into one that counts back the LEAST AMOUNT OF...

    I need to change this python program into one that counts back the LEAST AMOUNT OF COINS. Ex: if i input 44 as my change, how can i make it show 4 dimes and 4 pennies instead of 1 quarter, a dime, and 9 pennies? heres my code so far in PYTHON " cents=int(input("Please enter the change in Cents: ")) Quarter= int(cents/25)#25cents=1 Quarter Dime =int (cents%25/10)# 10 cents=1 Dime cents =(cents%25)%10 print(Quarter,"quarters",Dime,"dimes and",cents,"cents") "

  • Write a program with total change amount as an integer input, and output the change using...

    Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT