How to make a 2-dimensional array with n-rows and two columns
Show older comments
Write a script file that will compute the growth in a savings account at the end of every year for n-years. The script should prompt the user to input:
- ‘the initial account balance: ’
- ‘the annual interest rate: ’
- ‘the investment duration in years: ’
Use the formula n B= B (1+r) 0 &xf0d7; , where 0 B is the initial balance, r is the annual interest rate as a fraction, n is the number of years, B is the future value of the investment.
The script should display a 2-dimensional array with n-rows and two columns: The first column should display the years from 0 to n. The second column should display the account balance at the end of each corresponding year.
Test your program with $100 as the input for the initial balance; and, 6.5% as the input interest rate. The output should look like this:
0.0000 100.0000
1.0000 106.5000
2.0000 113.4225
3.0000 120.7950
4.0000 128.6466
5.0000 137.0087
. .
. .
. .
2 Comments
Walter Roberson
on 20 Nov 2015
Your formula is not understandable. Characters appear to be missing
The formula also involved the character with unicode code point U+F0D7 which is in the Private Use range and so might mean anything depending on which program is creating the graphics. When I reformatted your question, I represented the character as &xf0d7; which is one of the HTML representations for it.
Answers (1)
Walter Roberson
on 20 Nov 2015
n = 8; %for example
Array = zeros(n,2);
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!