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.
////////////////////////////////////////////
// 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;
}
Metro Bank Mortgage Calculator
//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)+”
” );
document.write(“The length of loan is “+length.toFixed(2)+” years
“);
document.write(“The annual interest rate is “+interest.toFixed(2)+”%
“);
document.write(“Your monthly payment is $ “+payment.toFixed(2)+”
“);
document.write(“Your total interest paid is $ “+INTEREST.toFixed(2));
In the second part of your javascript, you wrote:
It should be Java right? not Jave
Was this answer helpful?
LikeDislike1) Your script tags are wrong. It’s supposed to be
Was this answer helpful?
LikeDislike