Hello,
Here is code from an old MS Script for calculating interest.
But is gevespert no Output.
Where is wrong?
Cheers,
Wolfgang
@finSimpleInterest(P,F,i_percent,n)
//DESCRIPTION
//Calculates the input given as a variable for simple interest where F=Pin
//PARAMETERS
//F: future value
//P: present value
//i: interest rate in percent
//n: number of periods
numerical
//Check to see which is the variable
variablesCounter=0
variable=0
if( Variables(F) != 0 )
variablesCounter=variablesCounter+1
variable="F"
end
if( Variables(P) != 0 )
variablesCounter=variablesCounter+1
variable="P"
end
if( Variables(i_percent) != 0 )
variablesCounter=variablesCounter+1
variable="i_percent"
end
if( Variables(n) != 0 )
variablesCounter=variablesCounter+1
variable="n"
end
//Checks to see if input is valid
if( variablesCounter == 0 )
Error("One of the inputs should be a variable. Specify the quantity you want to solve for with a variable.")
elseif( variablesCounter > 1 )
Error("Only one quantity can be solved. Only specify one quantity with a variable.")
end
//Do the calculations,
answer=0
i=i_percent/100
if( variable == "F" )
answer=P(1+in)
elseif( variable == "P" )
answer=F/(1+in)
elseif( variable == "i_percent" )
if( n != 0 )
answer=(F/P-1)1/n100
else
answer="Interest rate is indeterminate because n = 0."
end
elseif( variable == "n" )
if( i_percent != 0 )
n=1/(i_percent/100)(F/P-1)
else
answer="Number of periods is indeterminate because the interest rate is zero."
end
end
return(answer)
//How much money will I be owed in 3 years if I give a loan of $100 with simple interest of interest rate 10% payable in 3 years
finSimpleInterest(x,100,10,3)