// currencybreak.cpp // Copyright © 2002 by Hiroshi Satori (webmaster@ultimatejourney.net) // UltimateJourney.Net // http://www.ultimatejourney.net/ #include void breakdown(int number); int main() { float input; int theNumber; cout << "Input amount of money: "; cin >> input; cout << "\n"; theNumber = (input * 100.0); if (theNumber <= 8) { theNumber++; // for some reason, numbers 8 and under get 1 subtracted from them ... this puts it back } breakdown(theNumber); return 0; } void breakdown(int number) { int curr[6] = {100, 50, 25, 10, 5, 1}; // the currency (dollar, fifty-cent, quarter, dime, nickel, penny) int count[6] = {0, 0, 0, 0, 0, 0}; // to count how much of each coin/dollar for (int i = 0; i <= 5; i++) { count[i] = number / curr[i]; number -= (count[i] * curr[i]); } cout << "Dollars: " << count[0] << "\n"; cout << "Fifty-cent: " << count[1] << "\n"; cout << "Quarters: " << count[2] << "\n"; cout << "Dimes: " << count[3] << "\n"; cout << "Nickels: " << count[4] << "\n"; cout << "Pennies: " << count[5] << "\n"; }