Comp 110L

Lab Project #2

Due: 9/2/2009

 

Write a Java program to make change when an item that costs less than a dollar is purchased and the buyer gives the seller a one dollar bill.  The goal is to provide the buyer as few coins as possible in the change.  The program must determine how many quarters, how many dimes, how many nickels, and how many pennies to return.  The ideal program would read in the cost of the item purchased, but for now your program should just set the cost of the item to be 22 cents.

 

You should start by first developing the algorithm to accomplish this and then write a shell Java program where each step of the algorithm is just expressed as a comment as was done for the program in the text that computes the area of a circle.  Once that is done you merely add the Java code to accomplish each step of your algorithm.

 

Turn in three items:

  1. A listing of your shell program with just the comments for each step of the algorithm
  2. A listing of your program that successfully compiles
  3. A listing of the output from your program