can someone help me to check this progeamming?HELP!!!!!!?


this is html with JavaScript inside. but it does not work. i cannot find out any errors.

<!–Jingyan Sun
July 20, 2010
CSC110
This is my week three homework. It is a Metro Bank Mortgage Calculator that calculate loan payments. the user will enter
the amount to borrow from the bank, the annual interest rate percentage, and the number of years. Then The program will
display the monthly payment and the total amount of interest that will be paid.
–>

<html>

<head><title>Metro Bank Mortgage Calculator</title>

<script language = "JavaScript">

////////////////////////////////////////////
// FUNCTION DEFINITION ///////////////////
////////////////////////////////////////////

/* compound — function to calculate monthly payment
* parameter A — amount of the loan
* parameter r — interest rate per period (for this calculation, each month is 1 period)
* parameter n — number of periods
* returns the future value after payment
* NOTE: A, r, and n are the traditional variable names in this equation
*/
function compound(A,r,n){
var a = A*r/(1-Math.pow(1+r,-n));
return a;
}

/* COMPOUND — fuction to calculate total interest paid
* parameter P — the monthly payment
* parameter n — the number of periods (each month is one period)
* parameter A — amount of loan
* NOTE: P, n, and A are the traditional variable names in this equation
*/
function COMPOUND(P,n,A){
var b = n*P-A;
return b;
}

</script>

</head>

<body>

<h1><img src="metro.jpg" img align="center" height="40%">Metro Bank Mortgage Calculator</h1>
<hr>

<script language = "JaveScript">

//declare the variables

var amount, length, interest, LENGTH, payment, INTEREST;

//input section

var amount = parseFloat(window.prompt("please enter the amount of loan you want",""));
var length = parseFloat(window.prompt("please enter the length of loan in years",""));
var interest = parseFloat(window.prompt("please enter the annual interest rate in percentage",""));

//process section

var LENGTH=12*length;
var payment = compound(amount,interest,LENGTH);
var INTEREST = COMPOUND(payment,LENGTH,amount);

//output sectin

document.write("The amout of loan is $"+amount.toFixed(2)+"<br>" );
document.write("The length of loan is "+length.toFixed(2)+" years<br>");
document.write("The annual interest rate is "+interest.toFixed(2)+"%<br><br>");
document.write("Your monthly payment is $"+payment.toFixed(2)+"<br>");
document.write("Your total interest paid is $"+INTEREST.toFixed(2));

</script>

</body>

</html>

2 Responses to can someone help me to check this progeamming?HELP!!!!!!?

  1. whizzopia

    In the second part of your javascript, you wrote:
    <script language = "JaveScript">

    It should be Java right? not Jave :)

  2. Ben

    1) Your script tags are wrong. It’s supposed to be
    <script type="text/javascript">
    though I think most browsers will accept the other tag anyway.

    2) You misspelled JavaScript in the second tag

Leave a Reply