0% found this document useful (0 votes)
517 views13 pages

Asc 454

The document contains code for various financial calculations including endowment insurance calculations, bond pricing calculations, time to deposit calculations, mortality rate and net single premium calculations for term insurance. It also contains code to generate odd and even numbers, calculate bonuses based on years of service, and calculate averages from input data. The code uses arrays, loops, and input/output functions to perform the necessary calculations and display results.

Uploaded by

SumaiyyahRoshidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
517 views13 pages

Asc 454

The document contains code for various financial calculations including endowment insurance calculations, bond pricing calculations, time to deposit calculations, mortality rate and net single premium calculations for term insurance. It also contains code to generate odd and even numbers, calculate bonuses based on years of service, and calculate averages from input data. The code uses arrays, loops, and input/output functions to perform the necessary calculations and display results.

Uploaded by

SumaiyyahRoshidi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

1

QUESTION 1
a)
Private Function endowment(age As Integer, interest_rate As Single, term As Integer,
sum_assured As Single, mort_rate() As Single, exp_rate As Single)

Dim x As Integer, disc_fac As Single, px(0 To 100) As Single,
Dim nPx(0 To 100) As Single, k As Integer
Dim m As Integer, n As Integer, APV_endowment As Single, ann_due As Single

disc_fac = 1 / (1 + interest_rate)
ann_fac = (1 - (disc_fac ^ term)) / interest_rate

For x = 0 To 99
mort_rate(x) = Sheet5.Cells(6, 3)
px(x) = 1 - mort_rate(x)
Next x

nPx(0) = 1
For k = 1 To term
nPx(k) = nPx(k - 1) * px(age + k - 1)
Next k

m = 1
For n = age To (age + term)
APV_term = APV_term + (mort_rate(n) * disc_fac^(m)) * nPx(m - 1)
m = m + 1
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

2

Next n

APV_endowment = APV_term + ((disc_fac ^ term) * nPx(age + term))
ann_due = (1 - APV_endowment) / (interest_rate / 1 + interest_rate)
endowment = (sum_assured * APV_endowment) / ((1 - exp_rate) * (ann_due))
End Function
@OR
A B C D
1
2
age 30
3
interest_rate 0.06
4
term 12
5
sum_assured 100000
6
mortality rate =(0.07)* ( EXP(0.03))
7
expenses_rate_year 0.03
8
9
Level Gross Premium 10089.1435546875

10
Gross Premium 46309.21875


Private Sub CommandButton1_Click()

Dim level_gross_premium As Single, gross_premium As Single, age As Integer, interest_rate
As Single, term As Integer, sum_assured As Single, mort_rate(100) As Single, exp_rate As
Single
Dim x As Integer, disc_fac As Single, px(100) As Single, nPx(100) As Single, k As Integer
Dim m As Integer, n As Integer, APV_endowment As Single, ann_due As Single

age = Sheet10.Cells(2, 3)
interest_rate = Sheet10.Cells(3, 3)
term = Sheet10.Cells(4, 3)
sum_assured = Sheet10.Cells(5, 3)
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

3

exp_rate = Sheet10.Cells(7, 3)

disc_fac = 1 / (1 + interest_rate)
ann_fac = (1 - (disc_fac ^ term)) / interest_rate

For x = 0 To 99
mort_rate(x) = Sheet10.Cells(6, 3)
px(x) = 1 - mort_rate(x)
Next x

nPx(0) = 1
For k = 1 To term
nPx(k) = nPx(k - 1) * px(age + k - 1)
Next k

m = 1
For n = age To (age + term)
APV_term = APV_term + (mort_rate(n)) * ((disc_fac) ^ m) * (nPx(m - 1))
m = m + 1
Next n

APV_endowment = APV_term + ((disc_fac ^ term) * nPx(age + term))
ann_due = (1 - APV_endowment) / (interest_rate / 1 + interest_rate)

'G(ann_due) = (SA* endow_ins ) + (exp_rate% * G)*(ann_due)
'G = (SA * end_ins) / ( 1 - % )*(ann_due)
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

4

level_gross_premium = (sum_assured * APV_endowment) / ((1 - exp_rate) * (ann_due))
Sheet10.Cells(9, 3) = level_gross_premium
gross_premium = level_gross_premium * ann_due
Sheet10.Cells(10, 3) = gross_premium
End Sub
b)
A B C D
1
2
3 Par_value 10000
4 interest_rate 0.04
5 coupon_rate 0.06
6 earliest_term 10
7 latest_term 20
8 Callable(yes/no) yes List (yes/no) by using data validation
9 redemption_value 10000
10
11 Bond Price 11622.17969 "=bondprice(C3,C4,C5,C7,C8)"

Private Function bondprice(par_value As Single, interest_rate As Single, coupon_rate As Single, term
As Single, callable As String)
Dim disc_fac As Single, ann_fac As Single, g As Single, redemption_value As Single, earliest_term As
Integer
disc_fac = 1 / (1 + interest_rate)

redemption_value = Sheet4.Cells(9, 3)
earliest_term = Sheet4.Cells(6, 3)

g = (par_value * coupon_rate) / redemption_value

If callable = "yes" Then
If interest_rate > g Then
ann_fac = (1 - (disc_fac ^ term)) / interest_rate
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

5

bondprice = redemption_value - (((redemption_value * interest_rate) - (par_value *
coupon_rate)) * ann_fac)
ElseIf interest_rate < g Then
ann_fac = (1 - (disc_fac ^ earliest_term)) / interest_rate
bondprice = (((par_value * coupon_rate) - (redemption_value * interest_rate)) * ann_fac) +
redemption_value
End If
Else
ann_fac = (1 - (disc_fac ^ term)) / interest_rate
bondprice = par_value * coupon_rate * ann_fac + redemption_value * disc_fac ^ term
End If

End Function
c)
A B C D E
1
2
3 Desirable_amount 10000
4 no.of years 10
5 interest rate 0.05
6
7 TYD =TYD(C3,C4,C5)

Private Function TYD(desirable_amount As Single, number_of_years As Integer, interest_rate As
Single)

Sn = (((1 + interest_rate) ^ number_of_years) - 1) / interest_rate

TYD = desirable_amount / Sn

End Function

ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

6

QUESTION 2
a)
A B C D E F G
1
2 age mortality_rate NSP(1-year term)
3 30 0.0021 0.000095429
4 31 0.0022 0.000195585
5 32 0.0023 0.000300524
6 33 0.0024 0.000410308



Private Sub CommandButton1_Click()
Dim mortality_rate(100) As Single, w As Integer, age(100) As Integer, Px(100) As Single, tpx As Single,
tqx(30 To 33) As Single, t As Integer
Dim interest_rate As Single, s As Single, NSP(100) As Single
For w = 0 To 3
mortality_rate(w) = Sheet3.Cells(3 + w, 3)
age(w) = Sheet3.Cells(3 + w, 2)
Px(w) = 1 - mortality_rate(w)
Next w
tpx = 1
For t = 0 To 3
tpx = tpx * Px(t)
tqx(t) = 1 - tpx
tqx(t) = Round(tqx(t), 6)
Next t
End Sub

Private Sub CommandButton2_Click()

CommandButton1 CommandButton2
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

7

Dim mortality_rate(100) As Single, w As Integer, age(100) As Integer, Px(100) As Single, tpx As Single,
tqx(100) As Single, t As Integer
Dim interest_rate As Single, s As Single, NSP(100) As Single, NPV(100) As Single, d As Single
For w = 0 To 3
mortality_rate(w) = Sheet3.Cells(3 + w, 3)
age(w) = Sheet3.Cells(3 + w, 2)
Px(w) = 1 - mortality_rate(w)
Next w
tpx = 1
For t = 0 To 3
tpx = tpx * Px(t)
tqx(t) = 1 - tpx
tqx(t) = Round(tqx(t), 6)
Next t
interest_rate = InputBox("please insert the interest rate")
d = interest_rate / (1 + interest_rate)
For s = 0 To 3
NPV(s) = (1 / (1 + interest_rate)) * tqx(s)
NSP(s) = NPV(s) / ((1 - NPV(s)) / d)
Sheet3.Cells(3 + s, 4) = NSP(s)
Next s
End Sub
b)
A B C D E F G H I J K
1
2 6.2 7.1 7.2 7.6 7.1 7.5 7 8.5 7 6.5
3 7 6.8 7.7 7.8 8.1 7.3 8.3 6.4 7 7.9
4

Private Sub CommandButton1_Click()
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

8

Dim k As Integer, num1(0 To 9) As Single, num2(0 To 9) As Single, totalsum As Single, count As
Integer, mean As Single
Dim t As Integer, sum_num_mean As Single, variance As Single
For k = 0 To 9
num1(k) = Sheet1.Cells(2, 2 + k)
num2(k) = Sheet1.Cells(3, 2 + k)

totalsum = totalsum + num1(k) + num2(k)
count = count + 2
Next k

mean = totalsum / count

For t = 0 To 9
sum_num_mean = (((num1(t) - mean) ^ 2) / count) + (((num2(t) - mean) ^ 2) / count)
variance = variance + sum_num_mean
Next t

MsgBox "mean = " & mean & " and variance = " & variance
End Sub







ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

9

c)
A B C D
1
2
age mortality rate NSP(2-year term)
3
20 0.0021 0.000282412
4
21 0.0022 0.000484074
5
22 0.0023 0.0006961
6
23 0.0024 0.000807706
7
24 0.0025
8
25 0.0026

Private Sub CommandButton1_Click()
Dim mortality_rate(100) As Single, w As Integer, age(100) As Integer, Px(100) As Single,
Dim tpx As Single, tqx(100) As Single, t As Integer, interest_rate As Single, s As Single
Dim NSP(100) As Single, APV(100) As Single, d As Single

For w = 0 To 5
mortality_rate(w) = Sheet3.Cells(3 + w, 3)
age(w) = Sheet8.Cells(3 + w, 2)
Px(w) = 1 - mortality_rate(w)
Next w

tpx = 1
For t = 0 To 5
tpx = tpx * Px(t)
tqx(t) = 1 - tpx
tqx(t) = Round(tqx(t), 6)
Next t


CommandButton1
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

10

interest_rate = InputBox("please insert the interest rate")

d = interest_rate / (1 + interest_rate)

For s = 0 To 3
APV(s) = ((1 / (1 + interest_rate)) * tqx(s)) + (((1 / (1 + interest_rate)) ^ 2) * tqx(s + 1))
NSP(s) = APV(s) / ((1 - APV(s)) / d)
Sheet8.Cells(3 + s, 4) = NSP(s)
Next s
End Sub

QUESTION 3
a)
i)

Private Sub CommandButton1_Click()
Dim k As Single, odd As String, even As String
ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

11


For k = 19 To 1 Step -1
If k Mod 2 = 0 Then
even = even + "," & k
Else
odd = odd + "," & k
End If
Next k
MsgBox "the odd number is " & odd
End Sub

(ii)

Private Sub CommandButton1_Click()
Dim k As Single, odd As String, even As String

ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

12

For k = 2 To 100
If k Mod 2 = 0 Then
even = even + "," & k
Else
odd = odd + "," & k
End If
Next k
MsgBox "the even number is " & even
End Sub
b)
Private Sub CommandButton1_Click()
Dim total_year_work As Integer, bonus As Single
total_year_work = InputBox("how many year(s) that you have been working with the company?")
If total_year_work <= 5 Then
bonus = 500
MsgBox " bonus = " & bonus
ElseIf total_year_work > 5 Then
bonus = 1000
MsgBox " bonus = " & bonus
End If
End Sub






ASC454 SUMAIYYAH BINTI ROSHIDI (2012995507)

13

C)
A B C D
1 column 1 column 2 column 3
2 22 72 47
3 23 4 13.5
4 44 12 28
5 34 67 50.5
6 10 33 21.5
7 33 10 21.5
8 67 34 50.5
9 12 44 28
10 4 23 13.5
11 72 22 47
#Green: input from user , blue : output

Private Sub CommandButton1_Click()
Dim k As Integer, num(0 To 100) As Single, t As Integer, s As Integer, average As Single

For k = 0 To 9
num(k) = Sheet2.Cells(2 + k, 2)
Next k

For t = 9 To 0 Step -1
Sheet2.Cells(11 - t, 3) = num(t)
Next t

For s = 0 To 9
average = (Sheet2.Cells(2 + s, 2) + Sheet2.Cells(2 + s, 3)) / 2
Sheet2.Cells(2 + s, 4) = average
Next s
End Sub
CommandButton1

You might also like