#include <iostream>
using namespace std;
// Function Prototypes.
int NormalizeMoney( int ) ;
int main( )
{
int dollars; // Number of dollars in change
int cents= 0 ; // Amount of change
int amount= 1 ; // Amount counter
cout << "Enter the amount of cents you wish to calculate.\n " ;
cout << "Enter 0 when finished.\n " ;
cout << "Enter amount of cents would you like to calculate: " ;
cin >> cents;
dollars = NormalizeMoney( cents) ;
while ( cents! = 0 )
{
amount+ = cents;
amount++ ;
cout << "Enter amount of cents would you like to calculate: " ;
cin >> cents;
dollars = NormalizeMoney( cents) ;
}
return 0 ;
}
int NormalizeMoney ( int cents)
{
double dollars= 0 ;
// Convert cents to dollars and cents.
dollars = ( ( float ) cents/ 100 ) ;
cents = cents - ( dollars* 100 ) ;
cout << "The Converted Amount is $" << dollars << endl;
static float sum= 0 ; // Local static variable.
// Accumulate a Running Total.
sum+ = dollars;
// Display Sum.
cout << "The Current Sum is: " << sum << endl;
return dollars;
}
ICAjaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgovLyBGdW5jdGlvbiBQcm90b3R5cGVzLgppbnQgTm9ybWFsaXplTW9uZXkoaW50KTsKCmludCBtYWluKCkKewogICAgaW50IGRvbGxhcnM7IC8vIE51bWJlciBvZiBkb2xsYXJzIGluIGNoYW5nZQogICAgaW50IGNlbnRzPTA7IC8vIEFtb3VudCBvZiBjaGFuZ2UKICAgIGludCBhbW91bnQ9MTsgLy8gQW1vdW50IGNvdW50ZXIKCgogICAgY291dCA8PCAiRW50ZXIgdGhlIGFtb3VudCBvZiBjZW50cyB5b3Ugd2lzaCB0byBjYWxjdWxhdGUuXG4iOwogICAgY291dCA8PCAiRW50ZXIgMCB3aGVuIGZpbmlzaGVkLlxuIjsKICAgIGNvdXQgPDwgIkVudGVyIGFtb3VudCBvZiBjZW50cyB3b3VsZCB5b3UgbGlrZSB0byBjYWxjdWxhdGU6ICI7CiAgICBjaW4gPj4gY2VudHM7CiAgICBkb2xsYXJzID0gTm9ybWFsaXpl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