Actually, super dali nalang po nito kasi given na yung formula. Ang gagawin mo nalang is i-convert yun to code. Anyway, ganito ang process.
Step 1 - Declaring input variables
Declare ka ng 3 input variables as stated from here:
1. "Users must provide their financial goal (the amount of money desired after the specified number of years have elapsed)".
- This will be the variable 'a', as provided sa formula.
2. "An interest rate".
- This will be the variable 'r', as provided sa formula.
3. "Length of investment in years"
- This will be the variable 'n', as provided sa formula.
Step 2 - Declaring the output variable
Then declare 1 output variable that will hold the result; the variable 'p' as provided sa formula.
Step 3 - Asking the user for inputs
Ask the user to input for the
1. "Future Value", and save that value to the variable 'a'.
2. "Interest rate", and save the value to the variable 'r'.
3. "Years", and save the value to the variable 'n'.
Step 4 - Calculation
Ang medyo mahirap lang na part dito is ang pag-compute ng exponent value. There are few ways to do this like: using while loop, Math.Pow (c# function), and etc. Para mas madali, use Math.Pow nalang para mas madali.
Visualize muna natin ang fomula.
1. Getting the interest value, output = (percentage value / 100).
Ex: output = (6.6 / 100) -> output = 0.066
2. Compute together with exponent value using Math.Pow function, Math.Pow(m,n).
where
m = value to compute
n = exponent
-> output = Math.Pow((percentage value / 100), 5 years)
Ex: output = Math.Pow((6.6 / 100), 5)
3. Final formula
p = a / (Math.Pow((1 + (r / 100)),n)
Ex: p = 15,000 / (Math.Pow((1 + (6.6 / 100)),5)
p = 15,000 / (Math.Pow(1.066),5)
p = 15,000 / 1.376531086012576
p = 10,896.96