Lab 3

Output Specifications

Generate a text file (named "myInvestment.txt") containing the parameters of a one-time investment and a table that gives the period by period details of  the investment. For each period, the table will display the balance at the beginning of the period, the interest earned during the period, and the new balance at the end of the period.

Input Specifications

The user will enter the investment parameters: the present value (in dollars), the nominal annual rate (as a percent but without the percent symbol), the compounding frequency (as an integer), and the term (in years as an integer). The compounding frequency is the number of periods per year. For example, if interest is compounded quarterly, there are four periods (i.e., four quarters) per year and the compounding frequency is four.

Process Specifications

The periodic interest rate is the nominal annual rate divided by the compounding frequency. (Don't forget to convert from percent to the decimal equivalent.) The number of periods is given by the number of years multiplied by the compounding frequency.

For period zero, there is no initial balance or interest (these are left blank). The final balance is the present value of the investment. This row is included in the table to indicate how much was in the account at the very beginning and is especially useful when illustrating the growth of the balance in the account over time.

For each of the remaining periods, the initial balance is the final balance from the preceding period, the interest for the period is the initial balance times the periodic interest rate, and the new final balance is the initial balance plus the interest. The interest for the period should be rounded to the nearest penny.

Format Specifications

Your output file should be formatted like the sample shown here:

Present Value: 1000.00
Nominal Annual Rate: 5.50%
Periods per Year: 4
Years: 3

Period   Initial Balance   Interest   Final Balance
------   ---------------   --------   -------------
   0                                        1000.00
   1             1000.00      13.75         1013.75
   2             1013.75      13.94         1027.69
   3             1027.69      14.13         1041.82
   4             1041.82      14.33         1056.15
   5             1056.15      14.52         1070.67
   6             1070.67      14.72         1085.39
   7             1085.39      14.92         1100.31
   8             1100.31      15.13         1115.44
   9             1115.44      15.34         1130.78
  10             1130.78      15.55         1146.33
  11             1146.33      15.76         1162.09
  12             1162.09      15.98         1178.07


The periodic interest must be rounded to the nearest penny because banks never pay fractional cents. The following C++ expression rounds a double value to the nearest hundredth:

double(int(100.0 * doubleValue + 0.5))/100.0

Right-click on the link, Lab03.cpp, and save the file in your user space. Complete the program and send it to me as an email attachment.