Real Application (part 2)
public static void main(String args[]) throws IOException
{ DataInputStream din = new DataInputStream(System.in);
System.out.println("Enter principal (e.g. 8250.00 :");
double bal = new Double(din.readLine()).doubleValue();
System.out.println("Enter annual interest rate (e.g. 10.25) :");
double intyr = new Double(din.readLine()).doubleValue() / 100.;
System.out.println("Enter number of years :");
short nyears = (short) new Integer(din.readLine()).intValue();
System.out.println("\nprincipal=" + bal + " interest=" + intyr
+ " years=" + nyears);
double intmo = intyr / 12.;
int npmts = nyears * 12;
double pmt = bal * (intmo / (1. - Math.pow(1. + intmo, -npmts)));
Java - An Introductory Language Tutorial
(E.A.Johnson)