My program is almost done, but when i try to convert a number into cents, it does not calculate the cents properly. So if i enter 325, it says i have 3 dollars and 325 cents and my running total is not working. Each time NormalizeMoney is called it should print out the sum before returning, but it is not.
#include <iostream>
using namespace std;
// Function Prototypes.
int NormalizeMoney(int);
int main()
{
int cents, dollars;
cout << "How many cents do you have: ";
cin >> cents;
dollars = NormalizeMoney(cents);
cout << "You have " << dollars << " dollars and " << cents << " cents!\n";
return 0;
}
int NormalizeMoney (int cents)
{
int dollars;
static int sum=0; // Local static variable.
// Convert cents to dollars and cents.
dollars = cents/100;
cents = dollars - cents;
// Accumulate a Running Total.
for (int i = 1;i <= sum; i++)
{
cout << "The Sum is : " << sum << endl;
sum+=dollars;
}
return dollars;
}