Here is the info and code
I have written (I am very new at this)
INFO
This program will track an investment plan to determine the amount
that will accumulate over a period of time. The inputs to the program
are:
iAmount Initial amount invested
mAmount Monthly amount invested
rate Yearly interest rate
nCompound Number of times per year the interest is compounded
nYears Number of years for the investment
the program should prompt the user for these values, then produce a
table that shows yearly values for the total amount invested and the
current value of the investment. The table should have three columns -
the Year number, the Amount Invested and the Current Value. Make sure
that the columns are aligned properly. Dollar amounts should be output
with two decimal places.
The formula to compute the balance of the investment is:
balance = amount * (1.0 + rate/nCompound)nPeriods*nCompound
where *amount* is the balance at the start of the period, *rate* is the
interest rate for one period of the investment, *nCompound* is the number
of times the investment is compounded per period, and *nPeriods* is the
number of periods for which the amount is invested.
To keep things simple, assume that the monthly amounts that are invested
are all added at the beginning of each year.
Write a value function to compute the balance. Your program will call
this function for each year of the investment. *(This means that the call*
*to the Balance() function will be made with *nPeriods* of 1 each time).*
The input is going to be this
0.00 Initial amount invested
500.00 Monthly amount invested
10 Yearly interest rate
12 Number of times per year the interest is compounded
35 Number of years for the investment
## Deliverables
CODE
// investment .cpp
// Programmer: Travis
// Date: Nov 22, 2003
//
// ---------------------------------------------------------
// This is a program that calculates an investment and prints
// it in table form
//
// ---------------------------------------------------------
#include <iomanip>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const float NPERIODS = 1.00;
float Balance ( float );
float iAmount ( float );
float table[][];
int col;
int row;
int y;
float curVal;
float mAmount;
float rate;
float nCompound;
int nYears;
int main()
{
cout << "Input the initial amount invested." << endl;
cin >> curVal;
cout << "Input the monthly amount invested." << endl;
cin >> mAmount;
cout << "Input the yearly interest rate." << endl;
cin >> rate;
cout << "Input the number of times per year the interest is compounded." << endl;
cin >> nCompound;
cout << "Input the number of years for the investment." << endl;
cin >> nYears;
table[0][0] = " Year ";
table[0][1] = " Amount Invested ";
table[0][2] = " Current Value ";
for ( int y = 1; y < nYears; ++y)
{
table[y][0] = y;
table[y][1] = iAmount ( curVal );
table[y][2] = Balance ( iAmount ( curVal ));
curVal = Balance (iAmount ( curVal ));
}
for ( row = 0; row < 36; row++)
{
for( col = 0; col< 3; col++)
cout << setprecision(2) << table[row][col];
cout << endl;
}
float iAmount ( float a )
{
return a = mAmount * 12 + curVal;
}
float Balance ( float b )
{
return b * pow ((1.0 + rate/nCompound),NPERIODS*nCompound);
}
}
return 0;
## Platform
C++