CS 117: Introduction to Computer Science
Change Maker

Assigned Wednesday, 1/9/02.
Due Monday, 1/14/02, electronically, by 11:10 AM.

Create a class named ChangeMaker with a main method that asks the user for a purchase price and an amount tendered, and then displays the change in dollars, quarters, dimes, nickels, and pennies. The user should enter in both numbers in cents, for example 3450 for $34.50 and 70 for $0.70. Use InputBox for input and OutputBox for output. Display the output in the following format:



 Purchase Price:   $34.5
Amount Tendered:   $40.

 Your change is:   $5.5

                   5 one-dollar bill(s)
                   2 quarter(s)

Thank you for your business. Come back soon.


Your answer should be the natural one, i.e. the one that gives away as little small change as possible. You may assume that both the purchase price and the amount tendered is less than $100, and greater or equal to $0.

Before stepping away from an assignment like this and moving on to other things, take a little time to think about what the assignment was for. Did the assignment increase your mastery of particular programming tools or language constructs? Did it illuminate some idea? Even a relatively dull assignment (making change is, I admit, not the most stimulating of computational tasks) is likely to have been assigned for a purpose, and you should make sure you understand what that purpose was.

Start early, have fun, and keep in touch.

Assignment from C. Thomas Wu, An Introduction to Object Oriented Programming With Java, McGraw-Hill, 2001.