CSCI120, Fall 2007


Assignment #4

DUE: Thursday, Sept. 27.


This assignment is an enhancement of the program ChangeMaker discussed in lecture and programming project 2.9, and enhanced in Lab 2. There are several problems with the program as it is, after its enhancement in the lab:

This is the assignment! Enhance ChangeMaker.java so that it can handle bigger bills, and has the nicer type of output as indicated above. Now getting all the commas and "and"'s just right is a bit more subtle than you might think, so work towards getting the plural vs. singular (e.g., "quarters" vs. "quarter") working, and eliminate the denominations that are 0 (so you never have an output like "0 nickels"). If you want to try to get the commas and "and"'s in their proper places, please do so but also keep the code as simple and readable as you can. A simple working program is better than a complicated non-working one.

Of course you need decision structures to do this. We have only discussed this in the context of pseudocode, but the Java syntax for the if-statement is straightforward. Look at the first 4 pages of L&L Chapter 5 for almost everything you need. You may need the "else" capability as well; again the syntax is easy, and we're just dealing with single statements. See page 217.

HINTS: As you develop your program, take small steps; the one thing not to do is to attempt to code everything at once! First get the program working for nickels and pennies. Then add the right functionality for dimes, etc.

Submit:

Back to CS 120 Home Page