Project 3 - Currency Type
|
It’s time for another project. You’re going to continue building on the fixed
type from Project 2 and incorporate what you’ve learned about locales and I/O. Your task this time is to write a currency
type.
The value is stored as a fixed-point value. I/O is formatted using the get_money
and put_money
manipulators.
Make sure you can add two currency amounts to get a currency value, subtract two currency amounts to get currency, multiply and divide currency by an integer or rational value to get a currency result, and divide two currency values to get a rational result.
As with any project, start small and add functionality as you go. For example, start with the basic data representation, then add I/O operators. Add arithmetic operators one at a time. Write each test function before you implement the feature.