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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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

This homework help was uploaded on 04/16/2008 for the course CSCI 1100 taught by Professor Hardwick during the Fall '08 term at Rensselaer Polytechnic Institute.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online