This assignment will help you put into use array and string constructs of C++. It also delves into function overloading.
!! **READ THE PROBLEM IN THE TEXTBOOK, NOT ONLY HERE** !!
a2_cheque: Deitel #5.45 (p. 386). Note: American students are forced to use the Canadian spelling in this assignment :)
The problem description in the book says to "assume that nine spaces are available." Our version will allow any number of spaces, and will throw a ChequeBufferOverflow exception if the converted string doesn't fit.
In addition, we will insert a currency symbol string at the start of the buffer. You will want to maintain this in a static char* variable. It should be global within cheque.cpp, but not external scope. It can be reset anytime by calling setChequeSym; otherwise, its default value is "$".
We will create two overloaded versions of chequeAmt, one for dollars and cents, the other for dollars only. Here are some samples of what the output should look like:
chequeAmt( buff, 10, 1234, 89 ); ==> "$*1,234.89"
chequeAmt( buff, 10, 1234 ); ==> "$****1,234"
chequeAmt( buff, 10, 0, 89 ); ==> "$*****0.89"
chequeAmt( buff, 10, 100, 389 ); ==> "$***103.89" // note cents > 99
chequeAmt( buff, 10, 0 ); ==> "US$******0"
chequeAmt( buff, 10, 0, 0 ); ==> "US$***0.00"
setChequeSym( 0 ); // restores default
We have chequeAmt return the buffer pointer so it can be used like this:
Implementation requirement: You must write the dollars and cents version so that it uses the dollars-only version to convert the dollars part. This avoids duplicating code. See cheque.h for special handling of cents > 99, and all other requirements. You will want to get familiar with the <cstring> library (p. 346-347).