Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loan amortization

Status
Not open for further replies.

rvarman

IS-IT--Management
Apr 24, 2003
91
0
0
FR
I'm new to java.
can anyone give me the java code for the loan amortization program.

Nb of payments
Capital(i) = Amount loanedt - Sum of 1 to i-1 of amortization

Interest(i) = Capital(i) * rate/ Nb of payments par yr

Monthly payment = (Principal* rate/ Nb of payments par yr) / ( 1 – (1 + rate / Nb of payments par yr) ^ (-Nb of payments))


Amortization(i) = Monthly payment(i) – Interest(i)


Thanks for your help

 
We are here to help professional programmers debug and solve their code problems, not to write entire programs for people.

If you are new to Java, I suggest taking a tutorial :

If you can post some code which you are having problems with, we'd me more than happy to help.
 
hi sedj,
Your ieda is not a constructive one.
If you could not suggest anything, please leave others to do.
I need the directions to proceed with.

To calculate Capital(i), i need the sum of the monthly payment.

Monthly payment(i) needs interest(i)
interest(i) needs capital(i)
So all these things are related.

Shd i construct a method to each (payment, interest, capital, etc=

Thanks for your suggestions.
 
You need a class that holds all parts of the calculation, and then a method which performs the calculation once all relevant variables are set

Something like this :

Code:
public class Calc {
  private int payment = 0;
  private int interest = 0;
  private int capital = 0;
  
  
  public void setPayment(int payment) {
  	this.payment = payment;
  }
  
  public int getPayment() {
  	return payment;
  }
  
  public void setInterest(int interest) {
  	this.interest = interest;
  }
  
  public int getInterest() {
  	return interest;
  }
  
  public void setCapital(int capital) {
  	this.capital = capital;
  }
  
  public int getCapital() {
  	return capital;
  }
  
  public int calculate() {
  	setCapital(interest *payment);
  	return getCapital();
  }
  
  
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top