> I am trying to code an assignment that calculates the
> payments for a mortgage of a loan amount using 3
> separate rates and term years. I have it working but
> it wants to calculate each loan 3 times with all
> three rates and with the years so instead of having
> the printout with 7 years, 15 years and 30 years I
> have each 3 times with the different interest rate.
> Any help is appreciated.
>
> Thanks
>
> Here is the code I have:
>

import java.io.*;  // java input output package
 import java.text.DecimalFormat;
class PaymentArray2
{
 public static void main(String[] arguments)
 {
  double amount = 200000;
  int[]term = {7, 15, 30};
  double[] rate = {.0535, .055, .0575};
   DecimalFormat twoDigits = new DecimalFormat("$000.00");
 
   System.out.println("With a loan amount of  " +twoDigits.format(amount));
  for (int i = 0; i < term.length; i++)
  {
   for (int j = 0; j < rate.length; j++)
   {
 
    System.out.print("for " + term[i] + " years");
    System.out.print("\tat a rate of " + rate[j]);
    double payment = (amount*(rate[j]/12))/(1-(Math.pow(1/(1+(rate[j]/12)),(term[i]*12))));
    System.out.println("\tThe monthly payment will be " + twoDigits.format(payment));
   }
  }
 }
}

your question is realy cunfusing, what I understand is you just want that:
7 years loan is calculated with 0.0535
15 years loan with 0.055
30 years loan with 0.0575
to get output like following

With a loan amount of  $200000.00
for 7 years     at a rate of 0.0535     The monthly payment will be $2859.79
for 15 years    at a rate of 0.055      The monthly payment will be $1634.17
for 30 years    at a rate of 0.0575     The monthly payment will be $1167.15

if yes code is following

import java.io.*;  // java input output package
 import java.text.DecimalFormat;
class PaymentArray2
{
 public static void main(String[] arguments)
 {
  double amount = 200000;
  int[]term = {7, 15, 30};
  double[] rate = {.0535, .055, .0575};
   DecimalFormat twoDigits = new DecimalFormat("$000.00");
 
   System.out.println("With a loan amount of  " +twoDigits.format(amount));

   for (int i = 0; i < rate.length; i++)
   {
   	System.out.print("for " + term[i] + " years");
    System.out.print("\tat a rate of " + rate[i]);
    double payment = (amount*(rate[i]/12))/(1-(Math.pow(1/(1+(rate[i]/12)),(term[i]*12))));
    System.out.println("\tThe monthly payment will be " + twoDigits.format(payment));
   }
  }
 }

if I'm wrong please clearly state what you want us to do :mrgreen:

Thanks that is exactly what I was looking for. I appreciate your help.

cool, just next time try to provide simple explanation or give an example :cheesy:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.