奥凯,我仍然对贾瓦有新鲜事,我正走到这一 st的第九周。 我将从一个学校项目上张贴一些来源代码——这是整个来源的NOT——这部法律是我摊还贷款的空档。 我试图从菜单选择(向文字领域打印)或用户投入中摊销。 问题在于,如果是数学,还是我的住所,那么我就不能说贷款没有适当摊销。 我只想知道,任何人是否看到我所忽略的一点显而易见,如果是,请指出这一点,我就可以走上正确的轨道? 提前感谢!
来源:
private void amortizeButtonActionPerformed( java.awt.event.ActionEvent evt ) {
// This module borrowed from Ryan Jones in George Griepp s PRG 420 class.
NumberFormat nf = NumberFormat.getCurrencyInstance();
int Monthly = 0;
int monthcount = 0;
String Output = "";
int i = 0; // For first loop
double loanamount = Double.parseDouble( tempTextField3.getText() ); //all loan amounts are the same
double rate = Double.parseDouble( tempTextField1.getText() ); //Array for the rate
double time = Double.parseDouble( tempTextField2.getText() ); //Array for the time
double totalnumpayments = 0; //Set for
double monthlypayment = 0; //Set for math calculation in first loop
double interestPayment = 0; //Set for math calculation in first loop
double totaltime = 0; //Set for second loop to know how long to loop
double loan = 0; //Set for second loop
double interestPayment2 = 0; //Set for second loop
double principlePayment = 0; //Set for second loop
for ( i = 0; i < time; i++ ) {//First loop This loops through the arrays and gives the first message listed below three times
monthlypayment = ( loanamount * ( ( rate / 12 ) / ( 1 - Math.pow( ( 1 + ( rate / 12 ) ), -( time * 12 ) ) ) ) );
interestPayment = loanamount * ( rate * 100 / 1200 );
totaltime = ( time * 12 );
jTextArea1.setText( "" );
jTextArea1.setText( "This loan has an interest rate of " + ( rate * 100 ) + "%" + " and a starting loan amount of " + nf.format( loanamount ) );
jTextArea1.setText( "Payment Number " + "Towards Principle " + "Towards Interest " + "Remaining on loan" );
jTextArea1.setText( "" ); // Part of the first loop this will appear three times with the math listed above
System.out.println( totaltime );
Monthly++;
Output += ( ( monthcount++ ) + " " + nf.format( principlePayment ) + " " + nf.format( interestPayment2 ) + " " + nf.format( loan - principlePayment ) + "
" );
loan = -principlePayment;// Changes the numbers as the loop goes
interestPayment2 = loan * ( rate * 100 / 1200 );// Changes the numbers as the loop goes
principlePayment = monthlypayment - interestPayment2;// Changes the numbers as the loop goes
}
jTextArea1.setText( Output );
}