fcn annuity (balance, interest, terms : real) : real
result balance * (1 + interest) ** terms
end annuity
fcn futureValue (balance1, interest1, terms1 : real) : real
result balance1 * ((1 + interest1) ** terms1 - 1) div interest1
end futureValue
var win := Window.Open ("position:top,center,notoolbar,graphics:300;400,")
var balance, balance1, interest, interest1, terms, terms1, num : real
var answer : string
loop
put " - You can calculate -"
put " - Annuities(1) -"
put " - Future Value(2) -"
put " - Both(1.2) -"
put " - or -"
put " - Exit(0) -"
put " - Selection: -" ..
get num
cls
loop
if num = 0 then
loop
Window.Close (win)
end loop
end if
if num = 1 then
put "Calculating Annuities"
put skip
put "Please enter in the balance: "..
get balance
cls
put "Please enter in the interest rate(as a decimal): " ..
get interest
cls
put "Please enter in the number of terms: " ..
get terms
cls
put "The value is: ", annuity (balance, interest, terms)
end if
if num = 2 then
put "Please enter in the balance: "
get balance1
cls
put "Please enter in the interest rate(as a decimal): " ..
get interest1
cls
put "Please enter in the number of terms: " ..
get terms1
cls
put "The value is: ", futureValue (balance1, interest1, terms1)
end if
if num = 1.2 then
put "Calculating Annuities"
put skip
put "Please enter in the balance: "
get balance
cls
put "Please enter in the interest rate(as a decimal): " ..
get interest
cls
put "Please enter in the number of terms: " ..
get terms
cls
put "The value is: ", annuity (balance, interest, terms)
end if
put skip
put "Do future value now?(y/n): " ..
get answer
cls
if answer = "y" then
put "Calculating Future Value"
put skip
put "Please enter in the balance: "
get balance1
cls
put "Please enter in the interest rate(as a decimal): " ..
get interest1
cls
put "Please enter in the number of terms: " ..
get terms1
cls
put "The value is: ", futureValue (balance1, interest1, terms1)
else
exit
end if
end loop
end loop
|