This assignment is a modification of the program that you wrote for Lab 7. In that assignment, you used parallel arrays to store the data. In this version of the program, you are to use a two-dimensional array of doubles to store all of the data (except n, the number of investments). We have been using integers to store the periods per year and the number of years. In this assignment we will use doubles. We've had to convert the integer values to doubles when we use them in arithmetic so, for now, we will also store them as doubles.

You will need three functions. One function will read all of the input data into the corresponding columns of the two-dimensional array. The second function will calculate the future values, the total interests, and the APYs, and store them in in the corresponding columns of the two-dimensional array. The third function will write the table described in the output specifications below to the output file.

Generate a text file named "Investments.txt" containing a table that gives the results of several lump-sum investments earning compound interest. Each line of the table represents one investment and contains the present value (dollars), the nominal annual rate (as a percent), the compounding frequency (monthly, quarterly, semiannually, or annually), the term in years, the future value (dollars), the total interest earned during the term of the investment (dollars), and the annual percentage yield (as a percent). The table columns are separated by two blank spaces and the table format is illustrated in the example below.

Present Nominal Compounding Future Total Value Rate Frequency Years Value Interest APY ---------- ------- ------------ ----- ---------- ---------- ------- 1000.00 5.25% Annually 10 1668.10 668.10 5.250% 1000.00 5.25% Semiannually 10 1679.05 679.05 5.319% 1000.00 5.25% Quarterly 10 1684.70 684.70 5.354% 1000.00 5.25% Monthly 10 1688.52 688.52 5.378% 1500.00 4.00% Quarterly 5 1830.29 330.29 4.060% 500.00 6.90% Monthly 3 614.63 114.63 7.122% 2500.00 3.93% Monthly 8 3421.84 921.84 4.002%

The investment parameters will be read from a text file named "Investments.dat". Each line of the file contains four numbers: the present value (in dollars), the nominal annual rate (as a percent but without the percent symbol), the compounding frequency (an integer), and the term in years (an integer). The number of lines in the file is unknown ahead of time. The results shown earlier were generated using this data file:

1000 5.25 1 10 1000 5.25 2 10 1000 5.25 4 10 1000 5.25 12 10 1500 4.0 4 5 500 6.9 12 3 2500 3.93 12 8

Calculate the future value, the total interest earned, and the annual percentage yield for each investment:

Variable |
Represents |
Formula |

FV | Future Value | FV = PV*(1+i)^{n} |

PV | Present Value | Given |

r | Nominal Annual Rate | Given |

ppy | Periods per Year | Given |

i | Periodic Rate | i=r/ppy |

t | Time in Years | Given |

n | Number of Periods | n=t*ppy |

I | Total Interest | I = FV - PV |

APY | Annual Percentage Yield | APY = (1+i)^{ppy} - 1 |

There is no exponentiation operator in C++. However, C++ provides a function that performs this useful operation:

pow(b, n) returns the value of b^{n}as a double

To use this function, you must include the cmath header file.