0
다음은 제 공식입니다. 올바른 결과물을 얻지 못하고 있습니다 ... 누군가가 "미래 가치"를 얻기 위해 (수익률로) 기여해야 할 월간 지불액을 찾고 있습니다 !! 나는 뭔가 잘못하고있다 .. 나는 그것이 정말로 간단하다고 믿는다. 고마워.플래시 수학 "Rate of Return"공개 토론? 혼란스러워!
//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;
}