/**************************************************
 * MakeChange program for calculating the change
 *   needed to return to a customer
 * by Heather, Sarah, Angela, David, and Chad
 * 2/8/2000
 *************************************************/

import javabook2.*;

class MakeChange {
    
    public static void main( String[] args) {
	
	// create the javabook objects
	MainWindow mw = new MainWindow();
	InputBox in = new InputBox(mw);
	OutputBox out = new OutputBox(mw);
	mw.show();
	out.show();

	// declare constants
	final int DOLLAR = 100;
	final int QUARTER = 25;
	final int DIME = 10;
	final int NICKEL = 5;

	// get Purchase Price + Amount Tendered
	int purchase = in.getInteger("What's the " + 
				     "purchase price?");
	int tendered = in.getInteger("What's the " + 
				     "amount tendered?");

	// calculations
	int change = tendered - purchase;
	int dollarbills = change / DOLLAR;
	change = change % DOLLAR;
	int quarters = change / QUARTER;
	change = change % QUARTER;
	int dimes = change / DIME;
	change = change % DIME;
	int nickels = change / NICKEL;
	int pennies = change % NICKEL;
	
	// output to the screen
	out.printLine("Your purchase cost : " + purchase + " cents");
	out.printLine("You payed          : " + tendered + " cents");
	out.skipLine(2);
	out.printLine("Your change is     : " + dollarbills + " dollars,");
	out.printLine("                     " + quarters + " quarters,");
	out.printLine("                     " + dimes + " dimes,");
	out.printLine("                     " + nickels + " nickels, ");
	out.printLine("                 and " + pennies + " pennies.");
    }
}
