If this is any part of an actual system, and not just a programming assignment, you will be well served to stay away from floating point numbers when adding currencies. See What Every Scientist Should Know About Floating-Point Arithmetic or search the monastery for floating point accuracy.
One thing that you can do is do your calculations in cents, and only do the conversion for display purposes ($cents / 100).
Update: Update to more long-lived link. Thanks to HalNineThousand below.
--MidLifeXis
In reply to Re: Force currency view
by MidLifeXis
in thread Force currency view
by htmanning
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |