Quote Originally Posted by Lindley View Post
You should separate the input and output format from the internal storage format. Even if you're counting cents internally (so that $157.03 becomes 15703 cents), that doesn't mean that you shouldn't be able to accept "157.03" as an input in dollars. You validate the input, then you convert it to your internal format. Similarly, you can convert your count of cents back to the conventional notation on ouput:

Code:
void outputmoney(ostream &out, int totalcents)
{
    int dollars = totalcents/100;
    int cents = totalcents%100;
    out << "$" << dollars << "." << cents;
}

outputmoney(cout, 15703); // test call
Thanks! that is a great explanation. I will try and figure it out and change my code. That should fix the problem. The double is causing the problem here. Thank you.