Question

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 pennies: 1000

Give the following change to the customer: 1 dollars, 2 quarters, 2 dimes, 0 nickels, and 2 pennies.

Enter the amount due in pennies: 456 Enter the amount received from the customer in pennies: 2000

Give the following change to the customer: 15 dollars, 1 quarters, 1 dimes, 1 nickels, and 4 pennies.

Enter the amount due in pennies: 401 Enter the amount received from the customer in pennies: 500

Give the following change to the customer: 0 dollars, 3 quarters, 2 dimes, 0 nickels, and 4 pennies.

For this assignment you may need to use tools available to you such as //(integer division) or %(remainder)

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

ue = int(input("Enter the amount due in pennies: "))
rec = int(input("Enter the amount received from the customer in pennies: "))

give = rec - due

dollars = give // 100
give = give % 100

quarters = give // 25
give = give % 25

dimes = give // 10
give = give % 10

nickels = give // 5
give = give % 5

pennies = give

print("Give the following change to customer: %d dollars, %d quarters, %d dimes, %d nickels and %d pennies. " %(dollars, quarters, dimes, nickels, pennies))

ee delhivery@dv-lt-n-014066:-/work En 1) 11:01 PM del × delhíve x delhiv v-It-n x delhi v-It-n × 1 delhív deLhtveryedv-It-n-0

COMMENT DOWN FOR ANY QUERY

PLEASE PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
In Python 3, Implement a program that directs a cashier how to give change. The program...
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
  • HELP ( i get these comment for this assignment please help me to fixed Please do...

    HELP ( i get these comment for this assignment please help me to fixed Please do not ask user to enter cents.  Amount due and received should be in dollars such as 2.35 and 5.) Business P2.8Giving change. 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. #include <iostream>...

  • (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...

  • *Create in Python 3: Change Calculator Create a program that calculates the coins needed to make...

    *Create in Python 3: Change Calculator Create a program that calculates the coins needed to make change for the specified number of cents. Sample Console Output Change Calculator   Enter number of cents (0-99): 99 Quarters: 3 Dimes: 2 Nickels: 0 Pennies: 4   Continue? (y/n): y Enter number of cents (0-99): 55   Quarters: 2 Dimes: 0 Nickels: 1 Pennies: 0   Continue? (y/n): n   Bye! Specifications The program should display the minimum number of quarters, dimes, nickels, and pennies that one needs...

  • Construct a program in C++ that exchanges coins for cash like Coinstar that is located in...

    Construct a program in C++ that exchanges coins for cash like Coinstar that is located in several grocery stores. You will prompt the user to provide you with the total number of pennies, nickels, dimes, and quarters, respectively.   You are to determine the total amount of money entered by the user and then output the cash that should be received. For example, if a user enters 50 pennies, 10 dimes, 10 nickels, and 5 quarters, then the user would receive...

  • 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?

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

  • Vending Machine (Python 3) Thinking Outside the box Write a program that asks the user to...

    Vending Machine (Python 3) Thinking Outside the box Write a program that asks the user to enter a bill value (1 = $1 bill, 5 = $5 bill, etc.) and the price of an item they want to buy in pennies and calculate their change amount in dollars, quarters, dimes, nickels, and pennies. Your code should start like this: ## # This program simulates a vending machine that gives change # Define constants PENNIES PER DOLLAR = 100 PENNIES PER...

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

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

  • I have this code for python: num = int(input()) if num == 0: print('No change') else:...

    I have this code for python: num = int(input()) if num == 0: print('No change') else: dol = num // 100 num %= 100 Quarters = num // 25 num %= 25 Dimes = num // 10 num %= 10 Nickels = num // 5 num %= 5 Pennies = num if dol > 0: if dol == 1: print('1 Dollar') if Dollars > 1: print(dol,'Dollars') if Quarters > 0: if Quarters == 1: print('1 Quarter') if Quarters > 1:...

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