Java Array Loop Quits After Shortest Array
<p>I'm trying to get three arrays to run through a loop at the same time.  The arrays are different lengths, and the loop quits after the shortest array is completed.  Any help is greatly appreciated:</p>

<pre><code>public class mortgagecalculator4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        double Loan1[] = {200000, 360, ((5.75 / 12) / 100)};//declares array
        //and defines variables for first loan 
        double Loan2[] = {200000, 180, ((5.50 / 12) / 100)};//declares array 
        //and defines variables for second loan
        double Loan3[] = {200000, 84, ((5.35 / 12) / 100)};//declares array
        //and defines variables for third loan
        double Payment1;//establishes variable for first payment
        double Payment2;//establishes variable for second payment
        double Payment3;//establishes variable for third payment
        double Interest1;//establishes variable for interest for loan 1
        double Interest2;//establishes variable for interest for loan 2
        double Interest3;//establishes variable for interest for loan 3
        double Balance1 = Loan1[0];//declares balance for loan 1
        double Balance2 = Loan2[0];//declares balance for loan 2
        double Balance3 = Loan3[0];//declares balance for loan 3
        double Principal1;// declares variable for principal 1
        double Principal2;// declares variable for principal 2
        double Principal3;// declares variable for principal 3

        Payment1 = (Loan1[0] * (Loan1[2])) / (1 - Math.pow(1 / (1 + Loan1[2]),
                Loan1[1]));//calculates monthly payment for first loan
        Payment2 = (Loan2[0] * (Loan2[2])) / (1 - Math.pow(1 / (1 + Loan2[2]),
                Loan2[1]));//calculates monthly payment for second loan
        Payment3 = (Loan3[0] * (Loan3[2])) / (1 - Math.pow(1 / (1 + Loan3[2]),
                Loan3[1]));//calculates monthly payment for third lona

        System.out.printf("The monthly payments are: Loan One:$%.2f  ",
                Payment1);//prints monthly payment amount for first loan
        System.out.printf("Loan Two:$%.2f  ",
                Payment2);//prints monthly payment amount for second loan
        System.out.printf("Loan Three:$%.2f\n",
                Payment3);//prints monthly payment amount for third loan
        System.out.printf("Each monthly payment breaks down as follows:\n");
        //displays 'each monthly payment...'


        for (int PaymentNumber = 1; PaymentNumber &lt;= Loan1[1]
                &amp;&amp; PaymentNumber &lt;= Loan2[1] &amp;&amp; PaymentNumber &lt;= Loan3[1];
                PaymentNumber++) {
            //creates 'for' loop that continues until the LoanTerm variable
            //is 0

            Interest1 = Balance1 * Loan1[2];//Determines amt paid toward interest
            Principal1 = Payment1 - Interest1;//Determines amt paid toward principal
            Balance1 = Balance1 - Principal1;//Creates new balance for loop

            PrintStream printf = System.out.printf(" Principal is: $%.2f", Principal1);
            //prints out the amount of principal paid
            System.out.printf(" Interest is: $%.2f", Interest1);
            //prints otu the amount of interest paid
            System.out.printf(" New balance is: $%.2f", Balance1);
            //prints out the new balance amount

            Interest2 = Balance2 * Loan2[2];//Determines amt paid toward interest
            Principal2 = Payment2 - Interest2;//Determines amt paid toward principal
            Balance2 = Balance2 - Principal2;//Creates new balance for loop

            System.out.printf(" Principal is: $%.2f", Principal2);
            //prints out the amount of principal paid
            System.out.printf(" Interest is: $%.2f", Interest2);
            //prints otu the amount of interest paid
            System.out.printf(" New balance is: $%.2f", Balance2);
            //prints out the new balance amount

            Interest3 = Balance3 * Loan3[2];//Determines amt paid toward interest
            Principal3 = Payment3 - Interest3;//Determines amt paid toward principal
            Balance3 = Balance3 - Principal3;//Creates new balance for loop

            System.out.printf(" Principal paid is: $%.2f", Principal3);
            //prints out the amount of principal paid
            System.out.printf(" Interest paid is: $%.2f", Interest3);
            //prints otu the amount of interest paid
            System.out.printf(" New balance is: $%.2f\n", Balance3);
            //prints out the new balance amount

            try {

                Thread.sleep(500);//tells program to sleep for two seconds
            } catch (InterruptedException ex) //catches any exceptions that are thrown
            {
            }
        }
    }
}
</code></pre>
