//--------------------------------------------------------- // Investments at Compound Interest // // Given the present value, the nominal annual rate, the // number of periods per year, and the number of years, // this program calculates the future value, the total // interest, and the APY (annual percentage yield). The // input comes from a file containing investment parameters // for an unknown number of investments. The ouput is in // tabular form and is written to a text file named // "Investments.txt". // // D. Searls // <-----------------YOUR NAME GOES HERE // Asbury University // Sep 2007 <---------------- CHANGE DATE //--------------------------------------------------------- #include #include #include #include using namespace std; int main() { ifstream infile; ofstream outfile; double pv; // Present value double r; // Nominal annual rate int ppy; // Periods per year int t; // Term in years double i; // Periodic rate int n; // Number of periods double fv; // Future value double totalInt; // Total interest double apy; // Annual percentage yield // Open the input and output files infile.open("Investments.dat"); outfile.open("Investments.txt"); // Write the table headings to the output file outfile << fixed; outfile << " Present Nominal Compounding Future Total\n"; outfile << " Value Rate Frequency Years Value Interest APY\n"; outfile << "---------- ------- ------------ ----- ---------- ---------- -------\n"; // TO DO: Read the data in the input file and write the body of the table // Close the input and output files outfile.close(); infile.close(); // Display a message on the display monitor cout << "See 'Investments.txt' for results.\n\n"; return 0; }