The rate of return
If the rate of return over a single period is
Let us assume that, at the beginning of the period, we invest a total sum S over
Write a program which reads the data from a file of name data.txt of the following format:
S;1000
n;8
w;r
0.05;0.1
0.2;0.01
0.12;0.05
0.18;0.02
0.15;0.02
0.15;0.05
0.1;0.01
0.05;0.03
and computes the rate of return and the final value of the whole portfolio by exploiting C-Style arrays.
The read data and the result must be printed on the screen and on a file named "result.txt".
The export format is:
S = 1000.00, n = 8
w = [ 0.05 0.2 0.12 0.18 0.15 0.15 0.1 0.05 ]
r = [ 0.1 0.01 0.05 0.02 0.02 0.05 0.01 0.03 ]
Rate of return of the portfolio: 0.0296
V: 1029.60
Remark: