Ok, im designing a compound interest calculator for university ... im still in the early stages this is my code:
<html>
<title>
</title>
<head>
<script language="JavaScript">
money=prompt("Enter the amount of money you wish to invest (£) :","1000");
interest=prompt("Enter the interest rate & :","2");
payments=prompt("Enter the length of time in months :","12");
</script>
</head>
<body>
<script language="JavaScript">
result=Math.round(money*(Math.pow((1+interest/100),payments))*100/100;
document.write(result);
</script>
</body>
<html>
For the moment... all I want is for it to display the answer just on the page.. just so I know its working and then I can progess to doing the table later.
Basically the line of code:
result=Math.round(money*(Math.pow((1+interest/100),payments))*100/100;
That is the calculation, when that line of code is put into the "head" part of my html documnent, it stops the prompt boxes appearing even though I put it after them"... but when its in the "body" section.. the prompt boxes appear but the answer doesnt.
Any ideas?
Cheers, A very confused bigmaddaz
Oh yea just incase my calulations are wrong... here is the formula im working from:
The formula to calculate compound interest is:-
A = p (1+r/100)n
where
a = amount on deposit at the end of the nth year
p = the original amount invested
r = the annual interest rate
n = number of years
<html>
<title>
</title>
<head>
<script language="JavaScript">
money=prompt("Enter the amount of money you wish to invest (£) :","1000");
interest=prompt("Enter the interest rate & :","2");
payments=prompt("Enter the length of time in months :","12");
</script>
</head>
<body>
<script language="JavaScript">
result=Math.round(money*(Math.pow((1+interest/100),payments))*100/100;
document.write(result);
</script>
</body>
<html>
For the moment... all I want is for it to display the answer just on the page.. just so I know its working and then I can progess to doing the table later.
Basically the line of code:
result=Math.round(money*(Math.pow((1+interest/100),payments))*100/100;
That is the calculation, when that line of code is put into the "head" part of my html documnent, it stops the prompt boxes appearing even though I put it after them"... but when its in the "body" section.. the prompt boxes appear but the answer doesnt.
Any ideas?
Cheers, A very confused bigmaddaz
Oh yea just incase my calulations are wrong... here is the formula im working from:
The formula to calculate compound interest is:-
A = p (1+r/100)n
where
a = amount on deposit at the end of the nth year
p = the original amount invested
r = the annual interest rate
n = number of years
Last edited: