com.cedarspring.tvm Class Amortization java.lang.Object | +--com.cedarspring.tvm.Amortization All Implemented Interfaces: java.io.Serializable ________________________________________ public class Amortization extends java.lang.Object implements java.io.Serializable This class represents the amortization for one payment period or a range of periods. It contains the total principal and interest paid, and the final balance at the end of the period. It is normally constructed and returned as a read-only object by the getAmortization(period1 [,period2]) method of the AmortizationSchedule class. Version: 1.2.2 15-May-2003 Author: Cedar Spring Software, Inc. See Also: Serialized Form ________________________________________ Field Summary private java.math.BigDecimal balance private java.math.BigDecimal interest private java.math.BigDecimal principal Constructor Summary (package private) Amortization() Create a new default Amortization object. (package private) Amortization(java.math.BigDecimal principal, java.math.BigDecimal interest, java.math.BigDecimal balance) Create a new Amortization object containing the principal, interest, and balance for one period or a range of periods. Method Summary java.math.BigDecimal getBalance() Get the remaining balance. java.math.BigDecimal getInterest() Get the interest portion of the payment(s). java.math.BigDecimal getPrincipal() Get the principal portion of the payment(s). Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Field Detail principal private java.math.BigDecimal principal ________________________________________ interest private java.math.BigDecimal interest ________________________________________ balance private java.math.BigDecimal balance Constructor Detail Amortization Amortization() Create a new default Amortization object. Principal, interest, and balance are 0. ________________________________________ Amortization Amortization(java.math.BigDecimal principal, java.math.BigDecimal interest, java.math.BigDecimal balance) Create a new Amortization object containing the principal, interest, and balance for one period or a range of periods. No checks are made for null values. Parameters: principal - Amount of the payment applied to principal. interest - Amount of the payment applied to interest. balance - Balance at the end of the period. Method Detail getPrincipal public java.math.BigDecimal getPrincipal() Get the principal portion of the payment(s). Returns: principal Principal portion of the payment. ________________________________________ getInterest public java.math.BigDecimal getInterest() Get the interest portion of the payment(s). Returns: interest Interest portion of the payment. ________________________________________ getBalance public java.math.BigDecimal getBalance() Get the remaining balance. Returns: balance Balance at end of period(s). ________________________________________

From the above it looks as if we can import an Amortization class at the beginning of a program, then call a subset of that class to perform calculations.

For instance if I had the following:

int [] loanNo = {1, 2, 3, 4}; int [] term = {84, 810, 360}; int [] rate = {5.35, 5.50, 5.75}; int [] payment = {2859.79, 1634.17, 1167.15};

and I am asking for and receiving user input like this:

System.out.println("Enter your choice of Loan 1, 2 or 3. Choose 4 to exit the program."); loanNo = System.in.read(); System.in.read(); //To take care of the carriage return System.in.read(); //To take care of the line feed System.out.println("You have chosen Loan No. " + loanNo);

My first question is how do I get from "You have chosen X" to using that value in my IF loop.

I propose those loops be as follows:

-------- (pseudocode):

If LoanNo == 1

Do calculations for Loan 1

Display loan amortization for Loan 1

If LoanNo == 2

Do calculations for Loan 2

Display loan amortization for Loan 2

If LoanNo == 3

Do calculations for Loan 3

Display loan amortization for Loan 3

If LoanNo == 4

Break

Else

"You have entered an invalid selection. Select a number from 1 to 3 or type 4 to exit program."

---------- (/pseudocode)

Question on Class Amortization: Does the Class Amortization have components that will handle calculating the payment, interest and balance due for each month of the chosen loan? For instance, it looks like I could put something like:

getBalance public java.math.BigDecimal getBalance()

and it would calculate a balance due. Would it, and if so, would it do so for each month in the loan period?

Thanks for any assistance you can provide.