{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

solution5 - amount = amount nickels*5 pennies = amount the...

This preview shows pages 1–2. Sign up to view the full content.

CSCI-1100 Computer Science I Rensselaer Polytechnic Institute Spring 2004 Studio 5 -- Solutions Problem 3: // Determine coinage for an amount of change #include <iostream> using namespace std; void change (float amount) { int origAmount; // same original amount for later int quarters; // number of quarters needed int dimes; // number of dimes needed int nickels; // number of nickels needed int pennies; // number of pennies needed // Save original amount for display later origAmount = amount; // Compute needed coinage quarters = amount / 25; // get quarters needed amount = amount - quarters*25; dimes = amount / 10; // get dimes needed amount = amount - dimes*10; nickels = amount / 5; // get nickels needed

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: amount = amount - nickels*5; pennies = amount; // the rest is pennies needed //Display the coinage needed to make change cout << "To make change of \$0." << origAmount << " you need:" << endl; cout << " " << quarters << " quarters" << endl; cout << " " << dimes << " dimes" << endl; cout << " " << nickels << " nickels" << endl; cout << " " << pennies << " pennies" << endl; } int main () { float amount; // amount of change needed // Get amount of change needed from user cout << "Enter amount of changed need in cents (less an \$1): "; cin >> amount; // Comput and display coinage for change change( amount ); return 0; }...
View Full Document

{[ snackBarMessage ]}