(a) w1 = 8000, wn = 0.98*w(n-1) - 250n/(n+1)
(b) w1 = 8000
w2 = 0.98*8000 - 125 = 7715
w3 = 0.98*7340 - 250*2/3 = 7394.0333
(c)
format bank
num = input('Input x >> ');
w = 8000;
r = 0;
disp('     n     wn in kg   rn in $')
for n = 1:num
  if w<0
    r = r - 1.5*w; % back does not exist kg to make daily sells
    w = 0;
    break;
  end;
  disp([n w r])
  w = w*0.98 - 250*n/(n+1);
  r = r + 1.5*250*n/(n+1);
end;
Output
Input x >> 20
     n     wn in kg   rn in $
     1.00    8000.00       0
     2.00    7715.00    187.50
     3.00    7394.03    437.50
     4.00    7058.65    718.75
     5.00    6717.48    1018.75
     6.00    6374.80    1331.25
     7.00    6033.02    1652.68
     8.00    5693.60    1980.80
     9.00    5357.51    2314.14
     10.00    5025.36    2651.64
     11.00    4697.58    2992.55
     12.00    4374.46    3336.30
     13.00    4056.20    3682.45
     14.00    3742.94    4030.66
     15.00    3434.74    4380.66
     16.00    3131.67    4732.23
     17.00    2833.75    5085.17
     18.00    2540.96    5439.33
     19.00    2253.30    5794.60
     20.00    1970.73    6150.85
Comments
Leave a comment