Don't know how to do this, looking for where to start
Author |
Message |
ylcc23
|
Posted: Tue Mar 29, 2016 10:29 pm Post subject: Don't know how to do this, looking for where to start |
|
|
Write a program that makes change for amounts less than one dollar. Input to the program should be a positive integer less than 100, representing an amount of money, in cents. Outputs should be the original amount of money together with a set of coins (quarters, dimes, nickels, cents) that could make up that amount. The program should produce change containing the minimum number of coins required for the given amount. The output should be in a natural, non-stilted form. For example, input of 58 should produce output something like
58 cents: 2 quarters, 1 nickel, and 3 cents.
Rather than
58 cents: 2 quarters, 0 dimes, 1 nickels, 3 cents.
I have a tiny bit so far, but I can't figure out what to do for the rest of it.
amount = int(input("Input an integer between 1 and 99: ")) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Wed Mar 30, 2016 5:17 pm Post subject: RE:Don\'t know how to do this, looking for where to start |
|
|
The div keyword will divide two integers without the remainder or decimal points. So 5 div 2 = 2.
The mod keyword will return the remainder of a division, so 5 mod 2 = 1.
Can you think of a way to use these keywords to complete this assignment? |
|
|
|
|
|
Srlancelot39
|
Posted: Wed Jul 19, 2017 8:27 am Post subject: RE:Don\'t know how to do this, looking for where to start |
|
|
The process is a lot like converting decimal to binary... |
|
|
|
|
|
|
|