Question
In this application, youll make a quick enhancement that shows not only the future value when interest is compounded yearly, but also when its compounded
In this application, youll make a quick enhancement that shows not only the future value when interest is compounded yearly, but also when its compounded monthly. As a result, the display in the browser should look like this:
Future Value with Yearly Interest Investment amount = 10000 Interest rate = 7.5 Years = 10 Future Value is 20610 Future Value with Monthly Interest Investment amount = 10000 Interest rate = 7.5 Years = 10 Future Value is 21120 Thanks for using the Future Value application.
Currently, can't figure out the for loop for monthly interest the formula I used to come up with 21120 is
The formula for annual compound interest, including principal sum, is: A = P (1 + r/n) (nt)
Where:
A = the future value of the investment/loan, including interest P = the principal investment amount (the initial deposit or loan amount) r = the annual interest rate (decimal) n = the number of times that interest is compounded per year t = the number of years the money is invested or borrowed for
Note that this formula gives you the future value of an investment or loan, which is compound interest plus the principal. Should you wish to calculate the compound interest only, you need this:
Total compounded interest = P (1 + r/n) (nt) - P
Future Value Application
Thanks for using the Future Value application.
var futureValue;
var monthlyValue;
// get user entries
var investment = prompt("Enter investment amount as xxxxx.xx", 10000);
investment = parseFloat(investment);
var rate = prompt("Enter interest rate as xx.x", 7.5);
rate = parseFloat(rate);
var years = prompt("Enter number of years", 10);
years = parseInt(years);
// calulate future value
futureValue = investment;
for (var i = 1; i <= years; i++ ) {
futureValue = futureValue + (futureValue * rate / 100);
}
futureValue = parseInt(futureValue);
// calulate Monthly value
monthlyValue = investment;
var month_rate = (rate / 12);
month_rate = Math.pow(1 + month_rate, 12) - 1;
// using a for-loop, recalculate value with rate each year
for (var i = 1; i <= years; i++) {
monthlyValue += monthlyValue * month_rate;
}
monthlyValue = parseInt(monthlyValue);
document.write(" Future Value with Yearly Interest ");
document.write("Investment amount = " + investment);
document.write(" Interest rate = " + rate);
document.write(" Years = " + years);
document.write(" Future Value is " + futureValue + " ");
document.write("Future Value with Monthly Interest ");
document.write("Investment amount = " + investment);
document.write(" Interest rate = " + rate);
document.write(" Years = " + years);
document.write(" Future Value is " + monthlyValue + " ");
Thanks for using the Future Value application.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started