Question

Python Programming

Write a program that asks the user to enter some amount of money and prints out exact change.
The program launguage is Python
Example of an output:

How much money do you have? 15.34



An ideal representation of 15.34 is:

15 dollars

1 Quarter

0 Dimes

1 nickel

4 Pennies

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

I can help you with python but I don't know what your question is, I see the assignment, what you have you tried so far and where did you getstuck?

there is something called the modulo operator, it looks like a percent %. What it does is division and returns the remainder.

so for example. 16.67%1 = .67, that would give us the dollars and we can subtract that from the total and we have 67 cents to deal with.

then we can do int(.67/.25) which would equal 2 (2 quarters) and use .67%.25 to find we have a remainder of 17 cents now.. and we just keep doing thattill we are left with pennies.

answered by: Lisely
Add a comment
Answer #2

What language?

In javascript:

var makeChange = function(price, payment){
return Math.round((parseFloat(price-payment)) * 100) / 100;
};

alert(makeChange(100,50.50));

answered by: Walker
Add a comment
Know the answer?
Add Answer to:
Python Programming
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
  • 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...

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

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

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

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

  • python 15166 Fall 2019 Midterm Your na 11. An acronym is a word formed by taking...

    python 15166 Fall 2019 Midterm Your na 11. An acronym is a word formed by taking the first letters of the words in a phrase and word from them. For example, MPG is an acronym for miles per gallon write a program that allows the user to type in a phrase and outputs the acronym for that phrase. Note: the acronym should be all uppercase, even if the words in the phrase are not capitalized 12. (10) Write a Python...

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

  • 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") "

  • in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949)...

    in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949) - joshfor x M Inbox (4,224) - joshuar X ® AC ads/ACFrOgA6UB 1k4Z1i1xGLNQ1Lntj510 lutEUaA..pdf ECE 175: Computer Programming for Engineering Applications Lab Assignment #2 (Thursday sessions) Relevant Programming Concepts: • Branch Structure • Loop Problem 1 (15 points): Develop a C program that asks a user to enter a total change amount in cents) and outputs the change using the fewest coins. The coin...

  • In Python, write a program that asks the user for a positive integer number. If the...

    In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686

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