I've been working on a problem that it just boggling my mind. I need to be able to convert a given number into change (i.e. quarters, dimes, nickels, pennies.) so if i type in 3.50 i get 14 quarters, if i type in 3.45 i get 13 quarters and two dimes etc. what i have so far is each number individually (i.e 3.50 gets me 14 quarters, 35 dimes, 70 nickels, 350 pennies) the question i have is, how am i able to do this? this is what i have so far
this code does each coinage individually, but i need them to be unifiedCode:#include <iostream> #include <iomanip> using namespace std; int main( ) { float amount; float quarters; float dimes; float nickels; float pennies; cout << "I will convert your money into change. \n\n"; cout << "Enter the amount:"; cin >> amount; quarters = amount/.25f; cout << "You recieve " << quarters << "Quarters.\n\n" ; dimes = amount/.10f; cout << "You recieve " << dimes << " Dimes.\n\n" ; nickels = amount/.05f; cout << "You recieve " << nickels << " Nickels.\n\n" ; pennies = amount/.01f; cout << "You recieve " << pennies << " Pennies.\n\n" ; return 0; }
ive tried many different things so far, to no avail.



LinkBack URL
About LinkBacks


