! 2.15a.f90 ! $Id: 2.15a.f90 1.4 2025/07/13 12:43:28 s Exp $ ! ! ii, an index stream ! bc, a Before-tax cash flow stream ! da, a Depletion stream ! ti, a Taxable income stream ! tax, a tax stream ! ac, an After-tax cash flow stream ! tr, a tax rate ! ir, an infration rate ! ic, an initial capital expenditure ! r, a discount rate ! df, a discount factor stream ! ny, a number of years ! pvac, a present value of ac program ex2_15a implicit none integer, parameter :: ny = 6 integer ii(ny) real(8) ic, ir, r, sumpv, tr real(8) ac(ny), bc(ny), da(ny), df(ny), pv(ny), tax(ny), ti(ny) character(80) fmt1, fmt2, fmt3 integer k ! input tr = 0.34d0 ir = 0.04d0 r = 0.12d0 ic = 10.0d6 ii(:) = (/(k, k = 0, ny - 1)/) bc(:) = (/ -ic, 2.99d6, 2.99d6, 2.99d6, 2.99d6, 2.99d6/) da(:) = (/0.0d0, ic/(ny-1), ic/(ny-1), ic/(ny-1), ic/(ny-1), ic/(ny-1)/) ! calculation ti(:) = 0.0d0 do k = 1, ny if(bc(k) - da(k) > 0d0) ti(k) = bc(k) - da(k) end do tax(:) = ti(:) * tr ac(:) = bc(:) - tax(:) df(:) = 1.0d0 / (1.0d0 + r) ** ii(:) pv(:) = ac(:) * df(:) sumpv = sum(pv(:)) ! output fmt1 = '(a5, a10, a10, a10, a10, a10, a10, a10)' fmt2 = '(i5, i10, i10, i10, i10, i10, f10.3, i10)' fmt3 = '(a65,i10)' write(*,*) '2.15a.f90' write(*,'(a5,f10.3)') 'tr=', tr write(*,'(a5,f10.3)') 'r=', r write(*, fmt1) 'y', 'bc', 'da', 'ti', 'tax', 'ac', 'df', 'pv' write(*,*) ('-', k = 1, 74) write(*, fmt2) (ii(k), int(bc(k)), int(da(k)), int(ti(k)), int(tax(k)), & int(ac(k)), df(k), int(pv(k)), k = 1, ny) write(*,*) ('-', k = 1, 74) write(*, fmt3) 'pv=', int(sumpv) end program ex2_15a ! end of file