The Money Class
Press Calculate.
How it works
The class keeps a sum in three fields: the sign, the whole part and the cents; they are shown under the result. The arithmetic and comparison operators are overloaded, so sums are added, multiplied and compared like numbers, and a plain number is first turned into a sum. A result is rounded to cents, and exactly half a cent goes to the even neighbour, as Math.Round does in C#: $200.55 at the rate of 1.2 is 167.125 euros and becomes €167.12. Dollars and Euros inherit from Money and differ in the currency sign and the exchange rate.
| Expression | In the lab | On this page |
|---|