// Bryan Simonson
// 10/06/09
// CS210 - Frank Lee - Assignment #1
//
// NOTE:
// The book is trying to mislead us into using the % operator for this assignment.
// This shall not be forgotten.
// 

#include <iostream>
using namespace std;

int main() {
	int dollars,quarters,dimes,nickels,pennies;
	double due,payment,change;


	// Get the amount due
	cout << "Please enter the price:\n";
	cin >> due;

	// Check the amount due for problems
	while (due <= 0.01) {
		// Somebody entered zero or less, probably trying to get some free money
		cout << "Sorry cheapskate, you must spend at least $0.01\n\n";
		
		// Ask again for the real price
		cout << "Please enter the ACTUAL price:\n";
		cin >> due;
		cout << endl;
	}
	
	// Get the payment amount
	cout << "Please provide payment amount (using numbers only):\n";
	cin >> payment;

	// Check payment amount for problems
	while (payment < due) {
		// Somebody is trying to pay less than what's due
		// but we're not accepting ANY money unless we get it all at once
		cout << "No, you owe $" << due << ", not $" << payment << ".\n\n";
		cout << endl << "Please provide FULL payment:\n";
		cin >> payment;
	}

	if (payment > due){
		// They paid more than what's due, time to give out change
		change = payment - due;
		cout << "----------------------------------------------\n";
		cout << "Your change is $" << change << endl;

		// dollars
		for (dollars = 0; change >= 1.00; dollars++){
			change -= 1.00;
		}
		
		// quarters
		for (quarters = 0; change >= 0.25; quarters++){
			change -= 0.25;
		}

		// dimes
		for (dimes = 0; change >= 0.10; dimes++){
			change -= 0.10;
		}

		// nickels
		for (nickels = 0; change >= 0.05; nickels++){
			change -= 0.05;
		}

		// pennies, just for good measure
		for (pennies = 0; change > 0.00; pennies++){
			change -= 0.01;
		}

		cout << "You get " << dollars << " dollars, " << quarters << " quarters, " << dimes << " dimes, " << nickels << " nickels, and " << pennies << " pennies.\n\n";
	} else {
		// They must have given exact change
		cout << "Thanks for using exact change!\n";
	}
	return 0;
}