Hello,
I am new member here I need help with my program.
I am trying to calculate interst for a loan I am not able to calculate last payment for loan like if loan amount is 1000 and interst rate is 18% which come up 1.5% for every month and if there is fix payment of 5% of the starting amount (1000) .
It was running and calculating all other then last payment but now its not even running some one cane help me I realy appreciate thanks.

import javax.swing.JOptionPane;
import java.awt.Container;
import javax.swing.*;
public class payment1 {


// main method begins execution of Java application
public static void main( String args[] )
{
float Interst,Payment,MonthInterst,TotalInterst=0,MonthlyNetPay,FinalPayment=0;
float monthlypay ,MonthsInterst;
String output,interstvalue,paymentvalue;
int months=0;



paymentvalue =
JOptionPane.showInputDialog( "Please enter the amount:" );


interstvalue =
JOptionPane.showInputDialog( "Please enter the interst rate" );


Payment = Float.parseFloat( paymentvalue);
Interst = Float.parseFloat( interstvalue );


output="The payment amount:"+Payment+"\nThe Interst is:"+Interst;
monthlypay= (5/100) * Payment;



while(Payment > 0)  {


MonthsInterst = Interst/12;
MonthInterst= ((MonthsInterst/100)* Payment);



TotalInterst = TotalInterst + MonthInterst;
MonthlyNetPay = monthlypay - MonthInterst;
Payment = Payment - MonthlyNetPay;


if (MonthlyNetPay >= Payment) {
FinalPayment = Payment;
System.out.println("FinalPayment");
}


months++;


}


output +="\nTotal Interst:"+TotalInterst+"\nThe Last Payment:"+FinalPayment;



JTextArea outputArea = new JTextArea();
outputArea.setText( output);


JOptionPane.showMessageDialog( null, outputArea,
"Grade Printing Program",
JOptionPane.INFORMATION_MESSAGE );



System.exit( 0 );
}
}

Your code is impossible to read ... no indentation ... no code tags ... no spacing ... no nothing ....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.