//----------------------------------------------- // Lab03.cpp // // Given the parameters of a lump-sum investment, // generate a text file showing the parameters // and a table with the period by period details. // // D. Searls // YOUR NAME GOES HERE // Asbury College // Sept. 2006 //----------------------------------------------- #include #include #include using namespace std; int main() { int ppy; // Periods per year (the compounding frequency) int t; // time in years int n; // number of periods double pv; // Present value double r; // Nominal annual rate double i; // periodic rate double initialBal; // Balance at beginning of period double interest; // Interest earned during period double finalBal; // Balance at end of period ofstream outfile; // The output file // Get the investment parameters cout << "Enter the parameters for a one-time investment." << endl; cout << endl; cout << "Present Value: "; cin >> pv; cout << "Nominal annual rate as a percent: "; cin >> r; cout << "Periods per Year: "; cin >> ppy; cout << "Number of Years: "; cin >> t; // TO DO: Calculate the periodic rate and the number of periods // Open the output file outfile.open("myInvestment.txt"); // Write the investment parameters // Write the column headings outfile << "Period Initial Balance Interest Final Balance" << endl; outfile << "------ --------------- -------- -------------" << endl; // TO DO: Write the period zero row // TO DO: Write the remainder of the table using a loop // Close the output file outfile.close(); // Display message on screen for user. cout << endl; cout << "The output is in the file 'myInvestment.txt'."; cout << endl; return 0; }