/* CIS 790 PROF. AUCIELLO */
import corejava.*;
class loancalc
{ public static void main(String args[])
{ double principal;
double yearlyInterest;
int years;
principal = Console.readDouble ("Loan Amount (no commas):");
yearlyInterest = Console.readDouble("Interest rate in % (use 7.5 for 7.5%): ")/100;
years = Console.readInt ("The number of years: ");
double y;
for (y= yearlyInterest - 0.01;
y<=yearlyInterest + 0.011; y += 0.00100)
{ double monthlyInterest = y / 12;
double payment = principal * monthlyInterest /
(1-(Math.pow((1/(1 + monthlyInterest)),years*12)));
Format.print(System.out," With rate %6.3f", 100*y);
Format.print(System.out," your payment is $%10.2f", payment);
System.out.println(" ");
}
}
}
Note structured format.