Programming Issues
Jason Friedman
jason at powerpull.net
Wed Sep 19 23:41:29 EDT 2012
> Ask the user for the amount of change expressed in cents. Your program must
> compute and display the number of half-dollars, quarters, dimes, nickels,
> and pennies to be returned.
> Return as many half-dollars as possible, then quarters, dimes, nickels, and
> pennies, in that order.
> Your program must allow the user to continue entering different amounts of
> change until they enter 0 to indicate they are finished. If the user enters
> a negative number, inform them of their mistake and ask them to enter a
> correct value.
Perhaps you can start with pseudo-code
(http://en.wikipedia.org/wiki/Pseudo_code) and ask for help writing
that in Python. I'll get you started.
Ask for a number.
If number = 0, stop.
If number < 0, ask again.
With values 50, 25, 10, 5 and 1:
if number > value:
coincount = integer portion of number divided by value
print coincount, value
remaining number = ...
I've broken the pseudo-code into two parts because they are, in some
sense, different programs.
You might try to write one, then the other.
In other words, starting by writing this in Python:
Ask for a number.
If number = 0, stop.
If number < 0, ask again.
If number > 0, print number and quit.
More information about the Python-list
mailing list