# C++ Investment with info and code

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 = " Year ";

table = " Amount Invested ";

table = " Current Value ";

for ( int y = 1; y < nYears; ++y)

{

table[y] = y;

table[y] = iAmount ( curVal );

table[y] = 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++

Về Bên Thuê:
( 1 Nhận xét ) United States

ID dự án: #3016479

## Được trao cho:

lehuray

See private message.

\$17 USD trong 2 ngày
(2 Đánh Giá)
0.8

## 6 freelancer đang chào giá trung bình \$24 cho công việc này

senzaciosnegyes

See private message.

\$21.25 USD trong 2 ngày
(104 Nhận xét)
4.9
RitchieM

See private message.

\$11.9 USD trong 2 ngày
(17 Nhận xét)
4.2
exceptionalcoder

See private message.

\$30.6 USD trong 2 ngày
(9 Nhận xét)
4.1
shashikhanvw

See private message.

\$34 USD trong 2 ngày
(15 Nhận xét)
3.8
thanasisk

See private message.

\$28.05 USD trong 2 ngày
(5 Nhận xét)
0.9