2010-11-22 4 views
0

Voici ma formule, Ne pas obtenir le bon rendement .... Je cherche le paiement mensuel que quelqu'un devrait contribuer (avec un taux de rendement%) pour obtenir leur "valeur future" !! Je fais quelque chose de mal .. Je crois que c'est vraiment simple .. Merci.Flash Math "Taux de rendement" forumula? Se confondre!

//set default input text 
var loanText = 100000; 
var interestText = 10; 
var yearsText = 1; 

//restrict the input boxes to numbers and symbols 
loan_txt.restrict = "0-9\\."; 
interest_txt.restrict = "0-9\\."; 
years_txt.restrict = "0-9\\."; 
// 
calculate_mc.onRollOver = function(){ 
    this.gotoAndPlay("over"); 
} 
calculate_mc.onRollOut = function(){ 
    this.gotoAndPlay("out"); 
} 
calculate_mc.onRelease = function(){ 
    if (loan_txt.text!="" && interest_txt.text!="" && years_txt.text!=""){ 
     loanPayments(); 
    }else{ 
     monthly_txt.text = "Please fill in all fields"; 
    } 
} 
// 
loan_txt.onSetFocus = function() { 
    if (loan_txt.text == loanText) { 
     loan_txt.text = ""; 
    } 
}; 
loan_txt.onKillFocus = function() { 
    if (loan_txt.text == "") { 
     loan_txt.text = loanText; 
    } 
}; 
interest_txt.onSetFocus = function() { 
    if (interest_txt.text == interestText) { 
     interest_txt.text = ""; 
    } 
}; 
interest_txt.onKillFocus = function() { 
    if (interest_txt.text == "") { 
     interest_txt.text = interestText; 
    } 
}; 
years_txt.onSetFocus = function() { 
    if (years_txt.text == yearsText) { 
     years_txt.text = ""; 
    } 
}; 
years_txt.onKillFocus = function() { 
    if (years_txt.text == "") { 
     years_txt.text = yearsText; 
    } 
}; 
loanPayments = function(){ 
    var loanAmount = loan_txt.text; 
    var interestRate = (interest_txt.text)/100; 
    var years = years_txt.text; 
    var downPayment = 0; 

    var monthRate = interestRate/12; 
    var numPayments = years*12; 
    var prin = loanAmount - downPayment; 

    monthPayment = Math.floor((prin*monthRate)/(1-Math.pow((1+monthRate),(1*numPayments)))*100)/100; 
       //form.NumberOfPayments.value=NumPayments 
    var getDec = String(monthPayment).indexOf("."); 
    var add0s = ""; 
    if(String(monthPayment).length +getDec == 2){ 
     add0s = "0"; 
    }else if(String(monthPayment).length +getDec == 1){ 
     add0s = "00"; 
    } 
    trace(add0s); 
    trace(monthPayment); 
    monthly_txt.text = "$"+monthPayment+add0s; 
} 

Répondre

0
monthPayment = (prin*monthRate)/(1-Math.pow(1+monthRate,-numPayments))