Need help with java prog

Reply

Join Date: Aug 2004
Posts: 1
Reputation: Rashid Riaz is an unknown quantity at this point 
Solved Threads: 0
Rashid Riaz Rashid Riaz is offline Offline
Newbie Poster

Need help with java prog

 
0
  #1
Aug 29th, 2004
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 );
}
}
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 54
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: Need help with java prog

 
0
  #2
Sep 5th, 2004
Your code is impossible to read ... no indentation ... no code tags ... no spacing ... no nothing ....
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC