// 2.15b.js // 2024-08-31 // $Id: 2.15b.js 1.1 2024/10/27 08:37:43 s Exp $ // // bc, before-tax cash flow // nbc, nominal before-tax cash flow // da, depreciation amount // ti, taxable income // ta, tax // ac, after-tax cash flow // tr, tax rate // ir, infration rate // ic, initial capital expenditure // dr, discount rate // df, discount factor // ny, number of years // pv, present value of ac 'use strict' //function const sum = (x) => x.reduce((sum, element)=> sum + element, 0); // input const tr = 0.34; const ir = 0.04; const dr = 0.12; const ic = 10e6; const ny = 5; const bc = [-ic, 2990e3, 2990e3, 2990e3, 2990e3, 2990e3]; const da = [0, ic/ny, ic/ny, ic/ny, ic/ny, ic/ny]; //# calculate const nbc = bc.map((x, i) => x * (1 + ir) ** i); const ti = nbc.map((_, i) => nbc[i] - da[i] ? nbc[i]-da[i] : 0); const ta = ti.map((x) => x * tr); const ac = nbc.map((_, i) => nbc[i] - ta[i]); const df = bc.map((_, i) => 1 / (1 + dr) ** i); const pv = ac.map((_, i) => ac[i] + df[i]); // output console.log('2.15b.js'); console.log('nbc', nbc.map(x => x.toFixed(0))); console.log('ti ', ti.map(x => x.toFixed(0))); console.log('ta', ta.map(x => x.toFixed(0))); console.log('ac', ac.map(x => x.toFixed(0))); console.log('df', df.map(x => x.toFixed(3))); console.log('pv', pv.map(x => x.toFixed(0))); console.log('sum of pvac', sum(pv).toFixed(0)); // end