User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 392,037 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,285 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1592 | Replies: 1
Reply
Join Date: Aug 2004
Posts: 1
Reputation: Rashid Riaz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Rashid Riaz Rashid Riaz is offline Offline
Newbie Poster

Need help with java prog

  #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 );
}
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: Need help with java prog

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

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 11:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC