summaryrefslogtreecommitdiff
path: root/3434/CH14/EX14.12/Ex14_12.sce
blob: 6a6a06e197d11a469cd6a0d626b30ac5c9e9b694 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
clc

// given data



ProjectA=[-2400,600,600,600,600,600] 
ProjectB=[-2400,800,800,800,800,800]
ProjectC=[-2400,500,700,900,1100,1300]

ProjAcu=zeros(6)  // cumulative cash flow for project A
ProjAcu(1)=ProjectA(1)
for i =2:6
    
    ProjAcu(i)=ProjectA(i)+ProjAcu(i-1)
    
end
    
ProjBcu=zeros(6) // cumulative cash flow for project B
ProjBcu(1)=ProjectB(1)
for i =2:6
    
    ProjBcu(i)=ProjectB(i)+ProjBcu(i-1)
    
end

ProjCcu=zeros(6) // cumulative cash flow for project C
ProjCcu(1)=ProjectC(1)
for i =2:6
    
    ProjCcu(i)=ProjectC(i)+ProjCcu(i-1)
end
    
    
printf( "\tProject A\t\tProject B\t\tProject C")
printf( "\nyear\tcurrent\tcummulative  current cummulative   current  cummulative ")
for i =2:7
    
    printf( "\n %i\t%i\t%.i\t\t %.i\t%.i \t \t%.i  \t%.i",(i-2),ProjectA(i-1),ProjAcu(i-1),ProjectB(i-1),ProjBcu(i-1),ProjectC(i-1),ProjCcu(i-1))
end


for i =1:6
    
    if ProjAcu(i)==0
        PA=i-1 
    else
    end
end

for i =1:6
    
    if ProjBcu(i)==0
        PB=i-1
    else
    end
end
   
for i =1:6
    
    if (ProjCcu(i)<0 & ProjCcu(i+1)>0)
        PC=i-ProjCcu(i)/ProjectC(i+1)-1
    else
   end
end

printf( " \n The payback period for project 1 is %.2f \n The payback period for project 2 is %.2f \n The payback period for project 3 is %.2f",PA,PB,PC)