Write a program to compute the amount of money you will have

Write a program to compute the amount of money you will have on an initial amount invested for a number of years at an annual percentage rate of interest. The user also adds a fixed amout to the investment each month. Show a table of the running amount each month (see below). Ask the user for the principal, the annual rate, the number of years and the amount he can afford to add to the investment each month. All dollar amount is to be rounded to two decimal places.

Use the following variable assignments and declarations in your program:  You can comment on the variables and list them one per line as follows and place a comment as to what they represent.

double

Principal, // holds principal

AnnRate, // holds the annual interest rate

MthlyDepositAmt, // to hold the monthly deposit amount

MthlyInterestRate, // to hold the monthly interest rate

NewAmount, // holds the new amount each month

InterestAmt; // holds the interest amount

int Years, // holds the years

Months; // holds the month number

get Principal // ask for the principal

get Years // ask for the number of years

get MthlyDepositAmt // ask for the monthly deposit amount

use the following statement before the loop to set the decimal precision to 2 - display the amounts rounded to two decimal places.

cout <<setprecision(2)<<fixed;

#include<iomanip> <= you must include this library

use the following statement in your loop to display the amounts in columns of 10 wide

cout <<setw(10)<<Months<<setw(10)<<InterestAmt<<setw(10)<<MthlyDepositAmt<<setw(10)<<NewAmount<<endl;

What is the principal? 500
What is the % annual rate? 12
How many years? 4
How much would you like to put away each month? 50
Month# Interest Monthly New
                Amount        Amount       Amount
1 5.00 50.00 555.00
2 5.55 50.00 610.55
3 6.11 50.00 666.66
4 6.67 50.00 723.32
5 7.23 50.00 780.56
6 7.81 50.00 838.36
7 8.38 50.00 896.74
8 8.97 50.00 955.71
9 9.56 50.00           1015.27
10              10.15           50.00           1075.42
11              10.75           50.00           1136.18
12              11.36           50.00           1197.54
13              11.98           50.00           1259.51
14              12.60           50.00           1322.11
15              13.22           50.00           1385.33
16              13.85           50.00           1449.18
17              14.49           50.00           1513.67
18              15.14           50.00           1578.81
19              15.79           50.00           1644.60
20              16.45           50.00           1711.05
21              17.11           50.00           1778.16
22              17.78           50.00           1845.94
23              18.46           50.00           1914.40
24              19.14           50.00           1983.54
25              19.84           50.00           2053.38
26              20.53           50.00           2123.91
27              21.24           50.00           2195.15
28              21.95           50.00           2267.10
29              22.67           50.00           2339.77
30              23.40           50.00           2413.17
31              24.13           50.00           2487.30
32              24.87           50.00           2562.17
33              25.62           50.00           2637.80
34              26.38           50.00           2714.17
35              27.14           50.00           2791.32
36              27.91           50.00           2869.23
37              28.69           50.00           2947.92
38              29.48           50.00           3027.40
39              30.27           50.00           3107.67
40              31.08           50.00           3188.75
41              31.89           50.00           3270.64
42              32.71           50.00           3353.34
43              33.53           50.00           3436.88
44              34.37           50.00           3521.25
45              35.21           50.00           3606.46
46              36.06           50.00           3692.52
47              36.93           50.00           3779.45
48              37.79           50.00           3867.24

--------------------------------
Process exited with return value 0
Press any key to continue . . .

Solution

#include<iostream>

#include<iomanip>

using namespace Amt;

int main()

{

double AnnualRate,MonthlyRate,MonthlyIntAmountt, Principal, NewPrincipal,HisAmount,intyears, months;

cout<<\"What is the Principle?\";

cin>>Principal;

cout<<\"What is the AnnualRate?\";

cin>>AnnualRate;

MonthlyRate=AnnualRate/12/100;// interest rate of 10%

cout<<\"How many years?\";

cin>>intyears;

intyears=4;

cout<<\"How much would you like to put away each month?\";

cin>>MonthlyIntAmount;

MonthlyIntAmount=50;

NewPrincipal =Principal;

for(months=1;months<= 12 * intyears;months ++)

{

MonthlyIntAmount=NewPrincipal*MonthlyRate;

NewPrincipal=MonthlyIntAmount + HisAmount + NewPrincipal;

cout<<setw(4)<<months<<setw(10)<<MonthlyIntAmount<<setw(5)<<HisAmount<<setw(12)<<NewPrinpal<<endl;

}

cin.get();

}

Write a program to compute the amount of money you will have on an initial amount invested for a number of years at an annual percentage rate of interest. The u
Write a program to compute the amount of money you will have on an initial amount invested for a number of years at an annual percentage rate of interest. The u
Write a program to compute the amount of money you will have on an initial amount invested for a number of years at an annual percentage rate of interest. The u

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site