
Untitled
By: a guest on
Apr 30th, 2012 | syntax:
HTML 5 | size: 1.45 KB | hits: 17 | expires: Never
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function calcInterestTable(){
var startAmount = parseInt(document.getElementById("startAmount").value);
var interestRate = parseInt(document.getElementById("interestRate").value);
var nextYearAmount = startAmount;
var newResults;
var year = 0;
var ruleOf72;
newResults = 'Interest Table \n\n';
while(nextYearAmount < (startAmount * 2)){
year++;
var addInterest = nextYearAmount * (interestRate/100);
nextYearAmount = nextYearAmount+addInterest;
newResults += 'By the end of year ' + year + ', you will have $' + nextYearAmount + ' overall. \n';
}
ruleOf72 = 72 / interestRate;
newResults += '\n By the Rule of 72 calculates to ' + ruleOf72 + ' \n\n';
document.getElementById("results").innerText = newResults;
return false;
}
</script>
</head>
<body>
<div>
<!-- <form name="0.1_input" target="_blank" onsubmit="return window.confirm("You are submitting information to an external page.\nAre you sure?");"> -->
Amount: <input type="text" id="startAmount"><br>
Interest Rate: <input type="text" id="interestRate"><br>
<!-- <input type="button" value="Calculate Years"> -->
<input type="button" onClick="return calcInterestTable();" value="Calculate Years">
<div id="results">
</div>
</div>
</body>
</html>