Well, I didn't spend time orgainizing it, but here:
Code:
<HTML>
<HEAD>
<TITLE> Last HOMEWORK </TITLE>
<SCRIPT type="text/javascript">
function monthlyRate(interest) {
var rate = interest / 100;
rate = rate + 1;
rate = (((1 + interest) + Math.pow(1, 12)) - 1);
return rate;
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT type="text/javascript">
var price = parseFloat(prompt("What was the purchase price for the item you are interested in buying?"));
var interest = parseFloat(prompt("What is the annual interest rate on your credit card?"));
var pay = parseFloat(prompt("How much do you plan to pay towards you credit card balance each month?"));
var monthly = monthlyRate(interest);
var bill = price;
var month = 0;
while (bill >= pay) {
bill = price - pay
bill = bill * (1 + monthly)
price = bill
}
if (bill < pay) {
var amount = pay * month + bill
alert("You have actually spend " + amount + " on this item")
}
</SCRIPT>
</BODY>
</HTML>
Bookmarks